Dec 3, 2009

Using xargs for rm & cp


Remove all files with .bak extension -

find . -name "*.bak" -type f -print | xargs /bin/rm -f

Remove all files with .bak extension who were last modified before today -

find . -mtime +0 -name "*.bak" -print | xargs rm

Copy all .html file to /tmp/movedhtml -

find . -name "*.html" -exec cp -p "{}" /tmp/movedhtml \;