Saturday, 15 May 2010

directory - Linux - Recursively go through directories? -



directory - Linux - Recursively go through directories? -

let's in directory /home/videos , want iterate recursively through of directories underneath it. if directory name contains "images" want delete directory , of contents. also, can done files? let's in each directory go through every file , check if name ends ".mp3" , delete it?

thanks

find . -name "*images*" -type d -exec rm -r {} \; find . -name "*.mp3" -type f -exec rm -rf {} \;

-exec rm -rf {} \; : delete files matched file pattern.

-type f : match files , not include directory names.

-type d : matches directory names

linux directory

No comments:

Post a Comment