LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-31-2004, 07:17 AM   #1
natalinasmpf
Member
 
Registered: Dec 2003
Distribution: Slackware 9.1
Posts: 309

Rep: Reputation: 30
The writer of rm is stupid.


I mean, its so stupid to make it such that:

Quote:
rm: cannot remove `.' or `..'
So I am forced to use a GUI to delete the folder (and its contents) of that file. Which is slow....slow....slow....

I mean, when I compiled a huge software, and I want to remove it (such as the CVS version of wine), I have make uninstall (or checkinstall) but if I want to remove the source entirely, its painsaking on a commandline. And commandline is faster at deleting files.

I mean, I WANT TO DELETE EVERYTHING INSIDE THE DIRECTORY.

And rmdir doesn't have an "empty directory" option. Thats stupid too.

I just want to get rid of everything, can't it do that for me, on a commandline, without typing the name of all 1000 files and folders inside the folder I want to remove?!!!

Thus I conclude, the writers of such programs are doing us a great inconvenience.
 
Old 01-31-2004, 07:20 AM   #2
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Ehm...


do you mean

rm -rf directory_name
 
Old 01-31-2004, 07:23 AM   #3
natalinasmpf
Member
 
Registered: Dec 2003
Distribution: Slackware 9.1
Posts: 309

Original Poster
Rep: Reputation: 30
No, I want to clear the contents of the directory (empty it) then remove the directory. I could be pleased with that.

But instead, in order to do so, I have to cd to each directory, rm each file invididually, then rmdir that directory...tiring!

I want the programs to empty the directory! Can't THEY do that?!

But yay, I decided to use make clean to minimise the file to 42 MB, (from 900 MB).

I am still annoyed though, for other stuff in the future. What if its not a source, but just as huge?

Thus the writers of rm are inflexible and stupid for failing to add an option to just simply empty the directory and erasing all the inodes the directory contains.
 
Old 01-31-2004, 07:29 AM   #4
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Maybe I'm missing what youre saying but if you do

rm -rf directory_name it will remove everything inside and including the directory or if
you cd into the directory and do

rm -rf *

it'll remove all the sub directories and contents (provided of course you have the appropriate permissions)
 
Old 01-31-2004, 07:31 AM   #5
natalinasmpf
Member
 
Registered: Dec 2003
Distribution: Slackware 9.1
Posts: 309

Original Poster
Rep: Reputation: 30
Okay, I take back that statement.

But you shouldn't have to do rm -R just to remove the contents.

It should do it automatically.

Its like starting a web browser and having to add the option "--proxy" to enable proxy servers.
 
Old 01-31-2004, 07:34 AM   #6
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
"." and ".." are special directory names. "." is the current directory. You can't delete it because your current directory would then be invalid.

".." is the parent directroy, the one that contains the current directory. You can't delete it for the same reason... If you deleted the directory that holds the current directory, the current directory would have to be deleted.

Besides, neither "." nor ".." is really there. Can you erase something that doesn't exist?

These two directories have nothing to do with your real problem of not being able to delete a directory with files in it. If you want more info on rm, you can look at the manual page with "man rm", or the simple help with "rm --help".

If you STILL feel something is wrong with the utility, maybe you should contact the authors. I'm sure they get right on it.
Quote:
AUTHOR
Written by Paul Rubin, David MacKenzie, Richard Stallman, and Jim Mey-
ering.

REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
 
Old 01-31-2004, 07:36 AM   #7
natalinasmpf
Member
 
Registered: Dec 2003
Distribution: Slackware 9.1
Posts: 309

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by ranger_nemo
"." and ".." are special directory names. "." is the current directory. You can't delete it because your current directory would then be invalid.

".." is the parent directroy, the one that contains the current directory. You can't delete it for the same reason... If you deleted the directory that holds the current directory, the current directory would have to be deleted.
I meant something like "./.", not the parent or current directory itself....
 
Old 01-31-2004, 07:47 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally posted by natalinasmpf
No, I want to clear the contents of the directory (empty it) then remove the directory. I could be pleased with that.

But instead, in order to do so, I have to cd to each directory, rm each file invididually, then rmdir that directory...tiring!
I don't understand the 2 step method (remove files first, then remove dir), this can be done in 1 step using rm:

All, including the directory itself and all underlaying dirs/files:
rm -rf <name_dir>

All files and underalying dirs, but not the dir itself
$ rm -rf <name_dir>/*

Remove files in <name_dir> and not the underlaying directories (and files in them):
$ rm <name_dir>/*

Remove files and 'dot'-files in <name_dir> and not the underlaying directories (and files in them):
$ rm <name_dir>/* <name_dir>/.*

For more complex removals use find and give the output to rm.

Quote:
rm: cannot remove `.' or `..'
Be glad that rm doesn't remove ..

Try ls -l .. and you understand why.
 
Old 01-31-2004, 08:34 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,748

Rep: Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927
Being forced to use options isn't necessarly a bad thing. Some distros add an alias so that you are forced into interactive mode. It can be very difficult to recover files once deleted. Have you ever read a post where someone was logged a root and by accident did a rm -rf on the wrong directory?

If you feel that typing a -R is too time comsuming then create just create an alias with whatever options you desire.
 
Old 01-31-2004, 09:43 AM   #10
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
The only thing I got to say about this issue is:

man pages are your friend, use them!
 
Old 01-31-2004, 10:30 AM   #11
lone_nut
Member
 
Registered: Dec 2003
Location: Denmark
Distribution: Mandrake
Posts: 179

Rep: Reputation: 30
You can also change the souce code, the rm is part of the gnu-core ultils package, and you can download it from www.gnu.org/software/coreutils/
 
Old 01-31-2004, 11:36 AM   #12
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
i hate man pages for 2 reasons, 1) its teh stupidest name i ever heard to call somthing and most importnat # 2) i don wanna install some stupid other program jsut to do what a normal text viewer can do (example : less)

but to this rm -fvr //* thingy, (mhm i dare anyone to try to enter that into teh promt and see if it dleetd all files starting with // in teh curent firectory (same logic apiles here as in .. or . just be glad it dont do it and find a way around it (for some reason i cant get ech to make files starting with a .
 
Old 01-31-2004, 12:08 PM   #13
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 60
The reason rm works as it does is for flexibility.

Hint: edit your .bashrc and alias a command to do what you want for a command you want to use, for example

alias nukeit='rm -R'

Then after you command source ./.bashrc, the command nukeit /path/to/directory will leave only /path/to when it ends.

See:
man rm
info rm

Also, you might be interested in Midnight Commander for console, then you won't need a gui file manager.
An Introduction to the Midnight Commander.
Midnight Commander home page

Last edited by fancypiper; 01-31-2004 at 12:12 PM.
 
Old 01-31-2004, 12:44 PM   #14
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
[QUOTE]Originally posted by SciYro
[B]i hate man pages for 2 reasons, 1) its teh stupidest name i ever heard to call somthing and most importnat # 2) i don wanna install some stupid other program jsut to do what a normal text viewer can do (example : less)

1. man page: Abbr. manual page
2. less simply shows and paginates the contents of a file for viewing without having to open it, besides less is good for more than just text files
just pipe the output of other commands into less to paginate thier output
for instance:

last | less (last 'pipe' less) paginates the output of the last command for easier viewing
dmesg | less shows and paginates the kernel boot up messages
toe | less shows all the termcap enteries in human readable form and paginates them

last,less, and toe are 3 commands that have output that unless you are mr. data from star trek have to be either paginated or '>'ed into a file and opened with a text editor, personally i prefer piping those ouptputs through less myself, as it's one step instead of two

so please, do a little research before just calling something 'stupid'
 
Old 01-31-2004, 05:36 PM   #15
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
At the end of the day without putting words in the posters mouth (which I obviosuly don't have any right to do) I think more than anything they were just letting off steam after a bit of frustation...hell I'd be in the electric chair and well fried by now going by some of the posts I've made before
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stupid, stupid question; I lost Klaptop. :( Surfrider Slackware 2 08-31-2005 09:12 PM
Cannot find DVD writer or get CD-writer to spin audio disk dgwebb Linux - Hardware 5 03-28-2005 05:00 PM
Stupid Dumb Stupid Question... drigz Linux - Software 3 09-23-2004 03:09 PM
stupid stupid newb ? what to use instead of xconfigurator h00ligan Fedora 3 01-25-2004 09:51 PM
need help with CD writer. qanopus Linux - General 4 12-08-2002 04:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration