Meaningless Drivel is fun!*
The moose likes Linux / UNIX and the fly likes Remove directory and files without answering question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Remove directory and files without answering question" Watch "Remove directory and files without answering question" New topic
Author

Remove directory and files without answering question

Sophia Choi
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
How can I remove directory and files without answering all questions?

rm -r *
Sophia Choi
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
If I remove some important directory and files in /usr/local, can I undelete them ?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Hmm. If you are likely to "accidentally" delete important things, I'm not sure I should give you the answer to your first question
The first rule with "rm" is always double check your "current directory". If you were to do "rm -r *" from / you could be in a whole heap of trouble.
If you get a load of questions when you use "rm", that probably means that the "rm" you are using is really an alias for "rm -i" (interactive delete). A lot of desktop Linux distributions seem to do this.
You can override this behaviour on a case-by-case basis using the "-f" (force) argument to "rm", e.g rm -f /tmp/abc123
If you don't ever want to see the questions again, you need to find where the alias is defined (maybe in ~/.profile) and remove the definition.
But above all, be careful. Unix and Linux are not systems which appreciate sloppy thinking. The commands are very powerful, and largely unforgiving. Don't even think of using "rm" if you might want something back later. If you want files out of the way, how about using something like "mv * /tmp/whatever" instead ? Then, if you are sure you didn't need it, you can use rm on the file(s) in /tmp/whatever later.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Remove directory and files without answering question
 
Similar Threads
Root drive in Unix corresponding to C:/ in Windows
NoClassDefFoundError
Exception when using JSTL <c:out> with EL expressions
Reg. Packages
Setting up Java on WinXP: PATH creation?