I want to see what files will be deleted when performing an
rm in linux. Most commands seem to have a dry run option to show just such information, but I can't seem to find such an option for
rm. Is this even possible?
Say you want to run:
rm -- *.txt
You can just run:
echo rm -- *.txt
or even just:
to see what files
rm would delete, because it's the shell expanding the
The only time this won't help you is for
If you want to remove files and directories recursively, then you could use
find instead of
rm -r, e.g.
find . -depth -name "*.txt" -print
then if it does what you want, change the
find . -depth -name "*.txt" -delete
-depth, we're still adding it as a reminder as recommended by the GNU
Just wanted to belatedly point out a handy solution that Joshua mentioned in the comments:
yes n | rm -i myFile1 myFile2 myFile3
rm in interactive mode, which prompts a y/n response for each file it would delete, but via
yes n it automatically declines this prompt for each file. The output isn't super pretty, but is parseable with a little cleanup.