I have a root folder with a text file in it called pairs.txt.Within that root folder are other folders with text files called pairs.txt in them.Is there a simple way to remove them using rm?I know that there I could use find . -name 'pairs.txt' -exec rm {} \; but I would like to know of other ways, perhaps using * or some other wildcard?I tried using rm -rf pairs.txt but it seems to only remove the pairs.txt in the current directory.
Removing specific files recursively using rm or something simple?
bash;rm;recursive
With bash 4+:shopt -s globstar dotglobrm -- **/pairs.txtThe globstar option makes ** match any number of directory levels. The dotglob option makes it include directories whose name begins with . (dot files).With ksh93, use set -o globstar instead of shopt -s globstar. To get the effect of dotglob, use FIGNORE=.With zsh, use the second line directly. To include dot files, run setopt glob_dots first or make the second line rm -- **/pairs.txt(D).Note that bash's ** follows symbolic links to directories. Ksh's and zsh's don't.