Friday, May 11, 2007

Find and remove files


To find and remove the .cpp extn files from the tesst directory and its sub-dirs, here is two way (very important, simple though)

$ find tesst/ -name *.cpp -type f
tesst/jks.cpp
tesst/asd.cpp
tesst/asdf/ina.cpp

Using xargs:
$ find tesst/ -name *.cpp -type f | xargs rm -f

Using exec:
$ find tesst/ -name *.cpp -type f -exec rm {} \;

No comments:

© Jadu Saikia www.UNIXCL.com