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:
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 . -name "*.txt" -print
then if it does what you want, change the
find . -name "*.txt" -delete
Just wanted to belatedly point out a handy solution that Joshua mentioned in the comments:
yes n | rm -i <whatever files you want to delete>
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.