Post History
If I just used find to generate a list of files, then find's -exec argument is usually the way to run some other program on each file found. If you pipe the command to xargs, note that -P n wi...
Answer
#2: Post edited
* If I just used find to generate a list of files, then find's -exec argument is usually the way to run some other program on each file found.If you pipe the command to xargs, note that `-P n` will run up to n commands in parallel. The best value of n will depend on the relative usage of your CPU and your storage system.* If I have a program that generates a list of files,`for filename in $(program); do otherprogram "$filename" ; done `is usually helpful. Make sure you quote your use of `$filename` -- more of them have spaces than you'd think.
- * If I just used `find` to generate a list of files, then find's `-exec` argument is usually the way to run some other program on each file found.
- If you pipe the command to `xargs`, note that `-P n` will run up to _n_ commands in parallel. The best value of _n_ will depend on the relative usage of your CPU and your storage system.
- * If I have a program (say, `generate_lists`) that generates a list of files,
- ```lang-bash
- for filename in $(generate_lists); do some_program "$filename" ; done
- ```
- is usually helpful. Make sure you quote your use of `$filename` -- more of them have spaces than you'd think.
#1: Initial revision
* If I just used find to generate a list of files, then find's -exec argument is usually the way to run some other program on each file found. If you pipe the command to xargs, note that `-P n` will run up to n commands in parallel. The best value of n will depend on the relative usage of your CPU and your storage system. * If I have a program that generates a list of files, `for filename in $(program); do otherprogram "$filename" ; done ` is usually helpful. Make sure you quote your use of `$filename` -- more of them have spaces than you'd think.