I've got a command foo that outputs a list of filenames:
$ foo file1.a file2.b file3.a And a command bar that accepts the names of .a files as arguments and does some processing:
$ bar file1.a file3.a Great success! $ bar file2.b FAILURE I'd like to combine the two with a pipe like foo | xargs bar, but I need to filter out all filenames that don't end in .a. How can I do this? Ideally I want something simple I can stick between the two commands in a pipe, like foo | filter-lines ".a" | xargs bar.
grep,sed,awk; and alsocut,paste,join. For the postgraduate text-processing tool you can learn Perl, but in 99% of cases you can accomplish everything you want with a simplegreporsedone-liner.xargsbut notgreporsed?