View previous topic :: View next topic |
Author |
Message |
defkewl Tux's lil' helper
Joined: 08 Feb 2005 Posts: 75 Location: Indonesia
|
Posted: Mon Feb 14, 2005 5:57 am Post subject: rmdir |
|
|
Hi there,
How do I remove a directory from command line interface if the directory is not empty?
I've tried looking for source on the net but could not find it.
Thnx in advance _________________ Not all things in life need reasoning
Visit my blog |
|
Back to top |
|
|
tdemarest Tux's lil' helper
Joined: 18 Mar 2003 Posts: 99 Location: California, USA
|
Posted: Mon Feb 14, 2005 6:16 am Post subject: |
|
|
From the man page:
Code: |
-f Do not prompt for confirmation. Do not write diagnostic messages. Do not produce an error return status if the only errors
were nonexisting files.
-i Prompt for confirmation. (In case both -f and -i are given, the last one given takes effect.)
-r or -R
Recursively remove directory trees.
|
|
|
Back to top |
|
|
Lokheed Veteran
Joined: 12 Jul 2004 Posts: 1295 Location: /usr/src/linux
|
Posted: Mon Feb 14, 2005 6:55 am Post subject: |
|
|
You dont need the f. A simple "rm -r /path/to/directory" is sufficient and wont prompt you. |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Mon Feb 14, 2005 8:05 am Post subject: |
|
|
Lokheed wrote: | You dont need the f. A simple "rm -r /path/to/directory" is sufficient and wont prompt you. |
It will prompt you if any files in that directory are not writable. |
|
Back to top |
|
|
etnoy Apprentice
Joined: 29 Aug 2003 Posts: 255 Location: Västerås, Sweden
|
Posted: Mon Feb 14, 2005 8:20 am Post subject: |
|
|
Remember that rm -r is very powerful. A wrong command as root could _WIPE_ your system. Use rm -r with extreme caution and use rmdir to delete directories you know are empty. _________________ The md5sum of the above post is 06280ccd85ef9deb49c336e7945f4b5c
God is dead! - Nietzsche
Nietzsche is dead! -God |
|
Back to top |
|
|
curtis119 Bodhisattva
Joined: 10 Mar 2003 Posts: 2160 Location: Toledo, Ohio,USA, North America, Earth, SOL System, Milky Way, The Universe, The Cosmos, and Beyond.
|
Posted: Tue Feb 15, 2005 11:56 pm Post subject: |
|
|
TrueDFX wrote: | Lokheed wrote: | You dont need the f. A simple "rm -r /path/to/directory" is sufficient and wont prompt you. |
It will prompt you if any files in that directory are not writable. |
In that case use -R instead of -r. It's the same as -rf _________________ Gentoo: it's like wiping your ass with silk. |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Wed Feb 16, 2005 3:34 am Post subject: |
|
|
curtis119 wrote: | In that case use -R instead of -r. It's the same as -rf |
Code: | $ mkdir dir; touch dir/file; chmod -w dir/file; rm -R dir
rm: remove write-protected regular empty file `dir/file'? |
|
|
Back to top |
|
|
curtis119 Bodhisattva
Joined: 10 Mar 2003 Posts: 2160 Location: Toledo, Ohio,USA, North America, Earth, SOL System, Milky Way, The Universe, The Cosmos, and Beyond.
|
Posted: Wed Feb 16, 2005 3:54 am Post subject: |
|
|
TrueDFX wrote: | curtis119 wrote: | In that case use -R instead of -r. It's the same as -rf |
Code: | $ mkdir dir; touch dir/file; chmod -w dir/file; rm -R dir
rm: remove write-protected regular empty file `dir/file'? |
|
as ROOT
Code: | lapbox ~ # mkdir dir
lapbox ~ # touch dir/file
lapbox ~ # chmod -w dir/file
lapbox ~ # rm -R dir
lapbox ~ #
|
as NON-ROOT
Code: | mike@lapbox ~ $ mkdir dir
mike@lapbox ~ $ touch dir/file
mike@lapbox ~ $ chmod -w dir/file
mike@lapbox ~ $ rm -R dir
rm: remove write-protected regular empty file `dir/file'? y
mike@lapbox ~ $
|
Sorry, I should have been more specific. _________________ Gentoo: it's like wiping your ass with silk. |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Wed Feb 16, 2005 4:32 am Post subject: |
|
|
As root, Code: | # mkdir dir; touch dir/file; chmod -w dir/file; rm -r dir | doesn't prompt either. That's probably because the file's writable, because you're logged in as root. |
|
Back to top |
|
|
curtis119 Bodhisattva
Joined: 10 Mar 2003 Posts: 2160 Location: Toledo, Ohio,USA, North America, Earth, SOL System, Milky Way, The Universe, The Cosmos, and Beyond.
|
Posted: Wed Feb 16, 2005 4:57 am Post subject: |
|
|
TrueDFX wrote: | As root, Code: | # mkdir dir; touch dir/file; chmod -w dir/file; rm -r dir | doesn't prompt either. That's probably because the file's writable, because you're logged in as root. |
hmm, your right. All this time I thought -R was a root specific flag. I've been doing it that way since 1990 or so. You learn something new everyday. _________________ Gentoo: it's like wiping your ass with silk. |
|
Back to top |
|
|
defkewl Tux's lil' helper
Joined: 08 Feb 2005 Posts: 75 Location: Indonesia
|
Posted: Wed Feb 16, 2005 3:14 pm Post subject: |
|
|
tdemarest wrote: |
From the man page:
Code: |
-f Do not prompt for confirmation. Do not write diagnostic messages. Do not produce an error return status if the only errors
were nonexisting files.
-i Prompt for confirmation. (In case both -f and -i are given, the last one given takes effect.)
-r or -R
Recursively remove directory trees.
|
|
Thnx very much. But my man page only list these options:
Code: |
Remove the DIRECTORY(ies), if they are empty.
--ignore-fail-on-non-empty
ignore each failure that is solely because a directory is non-
empty
-p, --parents
remove DIRECTORY, then try to remove each directory component of
that path name. E.g., ârmdir -p a/b/câ is similar to ârmdir
a/b/c a/b aâ.
-v, --verbose
output a diagnostic for every directory processed
--help display this help and exit
--version
output version information and exit
|
Why isn't it listed in my manual page? Hmmh. Anyway thnx alot. _________________ Not all things in life need reasoning
Visit my blog |
|
Back to top |
|
|
|