View Full Version : [all variants] Why doesn't rm --dry-run exist?
pedrogfrancisco
August 18th, 2008, 10:29 PM
The idea struck me from nowhere and I find it weird nobody has asked this before but...
How come nobody remembered to create an option to rm which would allow one to see the effect of the rm command but without actually doing it?
rm -s some_dir_to_be_deleted/
or/and
rm --dry-run some_dir_to_be_deleted/
from apt-get's man page:
-s, --simulate, --just-print, --dry-run, --recon, --no-act
No action; perform a simulation of events that would occur but do
not actually change the system. (...)
Oldsoldier2003
August 18th, 2008, 10:33 PM
Probably because rm has the -i and -I flags... a --dryrun or --simulate would be pretty useless for exceptionally large directories.
Thats just my personal take on it.
pedrogfrancisco
August 18th, 2008, 10:36 PM
You clearly haven't deleted all your Desktop's files because you were too lazy to write the whole directory name (yes it doesn't make sense, but it did happen ;) )
Plus on out-of-the-box things, like for instance, deleting all hidden files in a directory, a --dry-run option would be very nice...
Most people I know the first time that tried to delete all hidden files through the console made rm go to the parent directory and so on.....
Too Late
August 18th, 2008, 10:43 PM
I agree. It would be very nice feature! Yes, the -i option can do quite the same thing, but it's not very nice to press 'n' and 'enter' all the time. In addition, you have to press 'y' and 'enter' when it asks the "descend into directory" question.
pedrogfrancisco
August 18th, 2008, 10:44 PM
On second thought, one can test the correctness of one syntax doing an ls with the same string.
Which on the above example would be:
ls -lR ./.??*
to confirm that the string actually did what was expected (taken from here (http://www.labtestproject.com/linuxcmd/rm.html))
akabdog
November 15th, 2008, 01:06 AM
You could also use
#yes no | rm -ri *
this will work similarly to a dry run, it's automatically answering 'no' at the prompts
spibou
November 15th, 2008, 01:21 AM
But this way rm will not descend into directories at all so you won't get to see what it would erase inside those directories.
Denestria
November 15th, 2008, 01:43 AM
You clearly haven't deleted all your Desktop's files because you were too lazy to write the whole directory name
If you were too lazy to to enter the whole directory then you're probably going to be too lazy to do a --dry-run before actually executing the command.
spibou
November 15th, 2008, 01:47 AM
If you were too lazy to to enter the whole directory then you're probably going to be too lazy to do a --dry-run before actually executing the command.
Not to mention actually reading the output of the dry run ;-)
geirha
November 15th, 2008, 02:03 AM
You can use find to delete recursively.
find /some/path # Lists what will be deleted, add -ls to get a listing like "ls -l"
find /some/path -delete # Delete.
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.