xargs is SHINY!
Nov. 15th, 2006 10:15 amFound out some more today, during the instructor's tangent, that
To wit, some programs just don't take input from STDIN. This is one of the reasons for which
xargs is even more nifty than I thought.To wit, some programs just don't take input from STDIN. This is one of the reasons for which
xargs was created. example:
find foo bar baz | xargs ls -lad
This allowsls, which normally cannot be passed parameters, to only operate on the output of thefind, instead of the local directory. Also, I found out that the-dflag forlsensures that the directories are not expanded.example:
find foo -print0 | xargs -0 ls -lad
This, like above, allowslsoperate on the output of thefind. Additionally, the-print0argument on thefindmakes thefindable to read filenames with whitespace. This is done by swapping in a zero for the\s. Along with this, the-0flag onxargsallows it to read this modified output.