LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   The writer of rm is stupid. (https://www.linuxquestions.org/questions/linux-general-1/the-writer-of-rm-is-stupid-140664/)

natalinasmpf 01-31-2004 07:17 AM

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

Looking_Lost 01-31-2004 07:20 AM

Ehm...


do you mean

rm -rf directory_name

natalinasmpf 01-31-2004 07:23 AM

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.

Looking_Lost 01-31-2004 07:29 AM

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)

natalinasmpf 01-31-2004 07:31 AM

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

ranger_nemo 01-31-2004 07:34 AM

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

natalinasmpf 01-31-2004 07:36 AM

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

druuna 01-31-2004 07:47 AM

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.

michaelk 01-31-2004 08:34 AM

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.

trickykid 01-31-2004 09:43 AM

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

man pages are your friend, use them! ;)

lone_nut 01-31-2004 10:30 AM

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/

SciYro 01-31-2004 11:36 AM

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

fancypiper 01-31-2004 12:08 PM

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

frieza 01-31-2004 12:44 PM

[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'

Looking_Lost 01-31-2004 05:36 PM

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 :)


All times are GMT -5. The time now is 02:22 PM.