Xargs Stuff
Xargs is a very useful command.
I needed to copy all folders and files into a folder in the same directory.
eg. folder contains :
one
two
three
I needed to copy one and two into three so that it looked like :
three
use :
ls |grep -v three |xargs -t -I '{}' mv ./'{}' three/'{}'
The {} are for placeholders so you can specify where in the conmmand the input goes. If you need to test it first include the -p parameter thus :
ls |grep -v three |xargs -p -I '{}' mv ./'{}' three/'{}'
Use to remove the files if you have been zip bombed
unzip -l file.zip | awk '{print $4}' | xargs -n1 rm -rf
To recursively find matching files and move to new folder
find ./ -name "*.lrf" -print0 |xargs -0 -t -I "{}" mv "{}" /home/jezm/ebooks/lrf/
The print0 and -0 options prevent issues with blanks and newlines in filenames, this uses null character as separator.