xargs—constructs an argument list(s) and executes a command
xargs [ flags ] [ command [ initial–arguments ] ]
xargs allows you to transfer contents of files into a command line and dynamically build command lines.
Example A.70.
1 ls $1 | xargs -i -t mv $1/{} $2/{}
2 ls | xargs -p -l rm -rf
EXPLANATION
Moves all files from directory $1 to directory $2, and echos each mv command just before executing. Prompts (-p) the user which files are to be removed one at a time and removes each one.
|