UNIX Shells by Example (4th Edition)

 <  Day Day Up  >  

xargs ”constructs an argument list(s) and executes a command

xargs [ flags ] [ command [ initialarguments ] ]

xargs allows you to transfer contents of files into a command line and dynamically build command lines.

Example A.70.

1 ls xargs -i -t mv /{} /{} 2 ls xargs -p -l rm -rf

EXPLANATION

  1. Moves all files from directory $1 to directory $2 , and echos each mv command just before executing.

  2. Prompts (-p) the user which files are to be removed one at a time and removes each one.

 <  Day Day Up  >  

Категории