You could use
rm -i to be prompted for every single file it will remove. You can pipe
no into it repeatedly, (confusingly) using the
yes command, to just view prompts (rejecting all of them):
yes no | rm -i files/globs/options
EDIT in response to comments by @user63051
If you are concerned about dangerous flag combinations, you can specify
rm -i -- and anything after that will NOT be treated as an option. This of course means that for the
-r flag to work, you need to put it before
Another suggestion, if you want to try it, is to create a
dummy user that doesn't belong to any of the existing groups. If the
others permissions of your files don't include
write permission (they usually don't unless you specifically want that), you can just login as the other user (
su dummy) and do the
rm command. It won't have permissions to delete anything so it will simply complain about it. You can also do this to use the suggestion above (as double protection).
I should warn you that all the options that call
rm are a bit dangerous. I usually just prefix the entire command I want to run with
echo to see what arguments will bash give to the command (how it expands the wildcards and which files it finds). Then just remove
echo if everything looks fine. Notice that this won't list contents of recursively found files with
-r but you will see the directory it wants to destroy.
In essence - use
echo if you want to see what it does. Use
-- for protection from runaway flags. Use
-i just in case, it will ask about every file and you will notice if it asks about something you don't want to remove. Only if you really want to produce a list, one file per line, it makes sense to do anything else.