Find the answer to your Linux question:
Results 1 to 4 of 4
the rm command man pages discusses removing files or directories recursively. So what is meant by deleting a file or directory recursively? and what are some reasons for doing so?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    4

    remove recursively


    the rm command man pages discusses removing files or directories recursively.

    So what is meant by deleting a file or directory recursively? and what are some reasons for doing so?

  2. #2
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,134
    It means removing a directory, and everything in it.

  3. #3
    Just Joined!
    Join Date
    Feb 2010
    Posts
    16
    If you want to delete a directory/folder, you have to use -r. If the directory is empty, you can also use rmdir

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2007
    Location
    Salt Lake City, UT, USA
    Posts
    32
    As a general rule, anytime I am using rm -r, I will specify the entire path of the folder I wanted deleted recursively.

    For instance, if I want to delete the contents of directory lame-program from /opt/software/lame-program, I'll do
    Code:
    /opt/software/lame-program# rm -r /opt/software/lame-program/*
    instead of
    Code:
    /opt/software/lame-program# rm -r ./*
    Once, during a down-time window at work in the middle of the night, I meant to run the command as shown in the 2nd example, but forgot a pretty important part:
    Code:
    /opt/software/lame-program# rm -r /*
    . The missing dot means your root partition is going to get deleted recursively. It isn't a fun place to be in. After that experience, I always go non-lazy when rm -r is involved.

Posting Permissions

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