May 2000
Beginner
761 pages
18h 20m
English
xargs [ flags ] [ command [ initial–arguments ] ]
xargs allows you to transfer contents of files into a command line and dynamically build command lines. (See Linux man page for a long listing of all options.)
1 ls $1 | xargs -i -t mv $1/{} $2/{} 2 ls | xargs -p -l rm -rf 3 find . -type f | xargs grep -l "ellie" |
Explanation
Moves all files from directory $1 to directory $2, and echos each mv command just before executing.
Prompts ( -p) the user with files that are to be removed, one at a time, and removes each one.
The find command starts searching the current directory for plain files, and sends the list of files to xargs. xargs transfers the filenames to grep.
Read now
Unlock full access