just some notes

Find & delete

Sometime it happen that  I need to find all certain type of file or directory from a folder and sub folders and delete it. An example is if you have to copy a project under svn and you want to clean all folder from “.svn” folder.

Via linux shell:

$ find /absolute/or/relative/path  -type d -name ".svn" | xargs rm -r

If you have to delete file or folder with name first letter “A”:

$ find /absolute/or/relative/path -name "A*" -print0 | xargs -0 rm -r

The print0 and -0 parameter means that the name ending with null char, otherwise will be used spaces

Copy all pictures from subdirectories:

find . -type f -name “*.jpg” -print0 | xargs -0 cp -fR –target-directory=/path/to/destination

Leave a Reply

Powered by WordPress | Designed by Elegant Themes