I would like to rm
all files that end in ~
in both my current directory and all directories inside my current directory. I was under the impression that the flag -r
or -R
would do this; however, the following commands only remove files ending in ~
in my current directory and not the other directories inside my current directory:
rm *~ -r
rm *~ -R
Is it even possible to get rm
to perform as I want it to as explained here and, if so, how?
I use tcsh.
rm
doesn't expand patterns like*~
to lists of filenames itself; the shell is responsible for doing that beforerm
is ever started. For that reason, arguments to rm like-r
can't change how that process works.-r
) should go before positional arguments (like the filenames given here). Some tools support doing it the other way around, and others don't; assuming that no more option parsing is done after the first positional argument is the safe and compatible approach.