Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Removing Non Empty Directories

 
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please whats the syntax to use in removing non empty directories
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rm -R <directory_name>
-R switch means recursive deletation.
 
Saloon Keeper
Posts: 22520
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use "rm -rf" (recursive, force). I think plain '-R' fails if there are non-directory files in the tree you're trying to remove.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some explanation for -r, -R, or -f and combination of -rf

OPTIONS
The following options are supported for /usr/bin/rm and
/usr/xpg4/bin/rm:

-r Recursively removes directories and subdirectories in
the argument list. The directory will be emptied of
files and removed. The user is normally prompted for
removal of any write-protected files which the direc-
tory contains. The write-protected files are removed
without prompting, however, if the -f option is used,
or if the standard input is not a terminal and the -i
option is not used.

Symbolic links that are encountered with this option
will not be traversed.

If the removal of a non-empty, write-protected direc-
tory is attempted, the utility will always fail (even
if the -f option is used), resulting in an error mes-
sage.

-R Same as -r option

-f Removes all files (whether write-protected or not) in
a directory without prompting the user. In a write-
protected directory, however, files are never removed
(whatever their permissions are), but no messages are
displayed. If the removal of a write-protected direc-
tory is attempted, this option will not suppress an
error message.
 
See where your hand is? Not there. It's next to this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic