xargs
- Makes stdin as a command line argument
- useful for running a command a bunch of times
- Example: Search in all files for a variable name
$ find . name “*.cxx” | xargs grep var
4.This is equivalent to running grep on all *.cxx files in all subdirectories.
$ grep *.cxx
5. The above would only search files in current directory
xargs (is xtreme)
- Use -I{} to replace all occurrences of {} in the command with the standard input.
- Example (I use all the time): Run all the scripts in all subdirectories
$ find . name "*.sh" | xargs I{} sh {}
- Copy lots of files at once.
$ find . name '*.dat' | xargs I{} cp {} /folder/
0 comments:
Post a Comment