xargs

The xargs command is commonly used with find to perform a command on each of files that match the search critera, by piping the results of the find command into xargs.

find ./ -type f -print | xargs -i mv -f {} ./newdir

This will move all files from the current directory to newdir. Each result from the find command replaces the {} characters before mv is called. So, if the find command returns

file1.txt
file2.txt

then the following is executed:

mv -f file1.txt ./newdir
mv -f file2.txt ./newdir

Also see

Last modified: 07/05/06 18:50:06
Go to top

Related Pages

No related pages or links.

Login/out

Login

Forgot Password?
Go to top
Go to top