Results 1 to 10 of 10

Thread: Why doesn't rm --dry-run exist?

  1. #1
    Join Date
    May 2008
    Beans
    91
    Distro
    Kubuntu Development Release

    Why doesn't rm --dry-run exist?

    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?

    Code:
    rm -s some_dir_to_be_deleted/
    or/and
    Code:
    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. (...)

  2. #2
    Join Date
    Jan 2008
    Location
    /dev/null
    Beans
    2,793
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Why doesn't rm --dry-run exist?

    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.

  3. #3
    Join Date
    May 2008
    Beans
    91
    Distro
    Kubuntu Development Release

    Re: Why doesn't rm --dry-run exist?

    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.....

  4. #4
    Join Date
    Aug 2008
    Beans
    188
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Why doesn't rm --dry-run exist?

    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.

  5. #5
    Join Date
    May 2008
    Beans
    91
    Distro
    Kubuntu Development Release

    Re: Why doesn't rm --dry-run exist?

    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:
    Code:
    ls -lR ./.??*
    to confirm that the string actually did what was expected (taken from here)

  6. #6
    Join Date
    Nov 2008
    Beans
    1

    Re: Why doesn't rm --dry-run exist?

    You could also use
    #yes no | rm -ri *
    this will work similarly to a dry run, it's automatically answering 'no' at the prompts

  7. #7
    Join Date
    Jan 2008
    Beans
    173

    Re: Why doesn't rm --dry-run exist?

    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.
    Member of the Planetary Society.

  8. #8
    Join Date
    Aug 2008
    Location
    Sea of Discontent
    Beans
    170

    Re: Why doesn't rm --dry-run exist?

    Quote Originally Posted by pedrogfrancisco View Post
    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.

  9. #9
    Join Date
    Jan 2008
    Beans
    173

    Re: Why doesn't rm --dry-run exist?

    Quote Originally Posted by Denestria View Post
    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
    Member of the Planetary Society.

  10. #10
    Join Date
    Feb 2007
    Beans
    4,045
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Why doesn't rm --dry-run exist?

    You can use find to delete recursively.
    Code:
    find /some/path         # Lists what will be deleted, add -ls to get a listing like "ls -l"
    find /some/path -delete # Delete.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •