Linux Swiss army knife one liners [ Delete all the directories with specific extension]
Now a days i am using GIT for version control, so I had old repositories which contains .svn folders.
I wanted to remove all the .svn directories from the system.
While googling i found one useful command to delete all the directoris with one line,,
SYNTAX in Current Working Directory:
find . -type d -name <dir_name> -print0 | xargs -0 rm -rf
find . -type d -name .svn -print 0 | xargs -0 rm -rf
Find command takes many arguments.
I want to find all the directories starting with .svn so i used -type option
You can use -type with d option to specify the directory.
find . -type d -name .svn -print0 command will fetch all the directories starting with .svn
Now we are piping it with xargs
xargs command is designed to construct argument lists and invoke other utility. xargs reads items from the standard input or pipes, delimited by blanks or newlines, and executes the command one or more times with any initial-arguments followed by items read from standard input. Blank lines on the standard input are ignored.
Now by using rm command we will delete the files/folders.