Friday, June 22, 2007

Find a directory by name in linux

Command to find a directory by name in linux
>find /share/backup/ -type d -name '.svn' -ls
-type d == directory
-name '.svn' == all directories named .svn
-ls == converts unusual characters to C style escape sequences

To delete the list of directories returned by the above command execute
>find /share/backup/ -type d -name '.svn' | xargs /bin/rm -dr
xargs builds and executes command lines from standard input
/bin/rm -dr == remove command with the directory and recursive flags