First use the command find to find all the files with a specific pattern. The -print0 options is useful for xargs. -print0 seperates each result of find with a 0 character. Then pipe the content of find to xargs. Use the -0 option of xargs, if your paths contain spaces characters. The following command remove all the files with the .db extensions in the current directory and its subdirectories. find . -name *.db -print0 | xargs -0 rm -vf