rm is the Linux Posix command to remove and delete files or directories.

learn more… | top users | synonyms

1
vote
2answers
1k views

How can I remove a directory with rm - rf?

I try to remove a folder with rm -rf foldername … but it says rm: cannot remove folder :is a directory. What's wrong?
1
vote
3answers
260 views

How do I remove TextMate's temporary files using rm?

Note that I'm not trying to disable the creation of these files. I want to keep them around until I'm ready to commit changes to my source control. The files are scattered throughout many ...
1
vote
2answers
1k views

Remove all except one file and directory at path

I need to remove all the files in a directory except for one file and one folder. Up to the grep I can output the correct list of items I want to remove but when i add xags, nothing is deleted. this ...
5
votes
3answers
985 views

Why is the dreadful 'rm -rf /' even allowed? [closed]

We all know the destructive power of the following command executed as root: rm -rf / Related questions: How far will you get with a 'rm -rf /' deleting everything: # rm -rf / I fail to ...
18
votes
4answers
663 views

Getting rid of a file called “-d” [duplicate]

Possible Duplicates: How do I delete a file named "-p" from bash? How to delete file with this name on linux: -]???????q Removing "-rf" file in Unix I've ...
11
votes
2answers
17k views

Linux – cannot remove owned file with 777 permissions

I've couple of files that I cannot remove using rf -Rf command. I'm the owner of those file and the group assigned to those files is also a group my user is in. What's even weirder is that I can edit ...
2
votes
3answers
327 views

(Probably) trivial question about rmdir

I hope this isn't too trivial, but for some reason I can't get a simple command to execute. I'm writing a file manipulation script and I have several directories called test, test2, etc each ...
1
vote
0answers
152 views

I deleted a C file from my system using rm-rf [duplicate]

Possible Duplicates: How to recover a removed file under linux Undo an “rm -rf ~” command? I deleted a newly created C file from my system. My assumption was that I did a svn ...
4
votes
2answers
557 views

Safe substitute for OS X `rm`?

I am used to having rm to alias something safer. I have been using osx-trash, but once I upgrade to Ruby 1.9.2, this stops working. I know about trash-cli from Python, but I would much prefer ...
171
votes
8answers
8k views

How far will you get with an 'rm -rf /' command?

I've often wondered how far the system will actually get if you run rm -rf /. I doubt the OS would be able to erase itself (?) Bonus Question: After the command has been executed, will rm have ...
0
votes
2answers
1k views

Help. I ran “find / -mtime +1 -exec rm {} \;” by accident!

I'm very very tired, worked all night long, and I did't sleep for hours... So I'm like a zombie now... half awake, and half asleep. I was trying to clear a directory. Then I run the command cd to ...
3
votes
1answer
527 views

When does rm remove open files?

Particularly, I want to know what happens when I rm an open file and don't explicitly kill the process holding the file descriptor to that file. Will the file be removed when the system is shut down?
76
votes
12answers
39k views

Undo an “rm -rf ~” command?

I had a folder I didn't want named '~', so from the command line I typed rm -rf ~ and accidentally deleted my home folder (since ~ resolved to /home/username). Is there any way back or do I ...
0
votes
4answers
814 views

Remove files that don't end on “.py” using rm [duplicate]

Possible Duplicate: Remove all files but one with rm This is a very simple question and i dont know whether a solution exists or not. I have some files in a directory, assume i have .py ...
0
votes
2answers
2k views

How to restore /lib/libc.so.6?

I occasionally deleted my /lib/libc.so.6. By using LD_PRELOAD I successfully made a link of my /lib/libc-2.12.1.so file in my home folder and now most of the command works (cp, ln, etc...). But I ...
10
votes
6answers
10k views

How to delete all but one file in Unix? [duplicate]

Possible Duplicate: How to delete all files in a directory except some? How to delete all but one(or some) file in Unix? Something like rm -rf -ignore myfile.txt *
6
votes
6answers
5k views

Saying 'yes to all' using rm -i

Say I wanted to make sure I'm removing the right files first, so I did something like: rm -i * just to make sure that I'm okay with the files that I am removing. So this will ask me for each file. ...
0
votes
4answers
5k views

How to remove file (which has white space in name) from Unix?

How to remove file (which has white space in name) from Unix?
4
votes
3answers
6k views

Mac — remove all files with a certain extension from a directory tree [duplicate]

Possible Duplicate: Delete files recursively matching a name on the command line (OS X) I want to remove all files with extension .orig from my tree. The tree is deep. Is there an easy ...
9
votes
1answer
13k views

ls | grep | rm — How to format this command?

I'm trying to delete a bunch of files in a certain directory (on Mac OS X using Terminal) ls | grep \([1-9]\) | xargs rm should do the trick, but it doesn't. I'm trying to delete any file with a ...
0
votes
2answers
75 views

Remove files which have a certain syntax

I have a couple of files which follow this syntax: *_yyyy-mm-dd_hhhmmm.* Example: *_2010-01-01_00h10m.* *_2010-01-01_01h10m.* *_2010-01-01_02h10m.* *_2010-01-01_03h10m.* ... ...
4
votes
2answers
2k views

Bash to delete a files older than X days

So I have a cron setup to make backups of a folder into a tarball every hour. I would like to add into the shell script that I'm using the ability to have files deleted automagically after about three ...
3
votes
2answers
3k views

Remove everything except? [duplicate]

Possible Duplicate: Remove all files but one with rm In unix, to remove zip files in a directory one can simply type rm *.zip How can one remove everything except zip files?
1
vote
1answer
88 views

rm'd dirs in Users/home/ reappear in OSX [duplicate]

Possible Duplicate: Stop Mac OS from re-creating ~/Pictures, ~/Music, or ~/Public Hi, I su'd to root and deleted some stock directories in my home folder such as Documents, Music, Pictures ...
2
votes
4answers
8k views

Remove all files except for a few, from a folder in Unix [duplicate]

Possible Duplicate: How to delete all files in a directory except some? I often face this problem. I have a set of files in a folder and would like to delete all of them except a few. For ...
6
votes
3answers
6k views

How to delete file with this name on linux: -]???????q

Somehow a file named -]???????q got created on my terminal. I tried rm -f "-]???????q" (in double quotes), but it did not get deleted. (Error:: rm: invalid option -- ]). How do I delete it?
8
votes
1answer
1k views

Remove all files but one with rm

Is there any way to remove all of the files in a directory except for one with a certain filename? For instance, if I had a directory containing the files file1, file2, and dontdelete. Would there be ...
1
vote
1answer
198 views

Can I list file names (or their parent directories) that were recently deleted using rm in OS X?

Is it possible to find out which files and directories have recently been deleted by rm in OS X? Or failing that, is it possible to find which parent directories have had files or directories within ...
2
votes
3answers
408 views

How to use “rm” to remove files with a “:” in them?

I am using Ubuntu 10.04, and I have a directory with a bunch of files. We changed the naming scheme of the files a while ago, and now I want to delete all the old ones. New Name scheme: ...
2
votes
4answers
1k views

Mac keyboard shortcut to rm file [duplicate]

Possible Duplicate: Permanently deleting files on Mac OS What's the Mac keyboard shortcut to rm a file? I know command + delete sends it to trash, but I want to permanently delete it, say ...
1
vote
1answer
1k views

How do I remove someone else's subdirectory from under my directory?

I was sharing files with a coworker on a Linux server, and he added some new files. Now we've moved the files somewhere else, so I'd like to remove the old files. However, when my coworker added his ...
4
votes
3answers
1k views

Removing file with strange characters in filename in OS X

After a memory error in my program, I am stuck with a file with a strange filename. It's proving quite resistant to all normal methods to remove files with strange names. The filename is: ...
0
votes
2answers
622 views

rm a corrupt file

I am trying to remove a file using rm. However, if I do ls, all the information about the file is ?????? ?? ?? example.txt... And calling rm returns that no such file exists. How can I force a remove ...
2
votes
3answers
520 views

Why does rm -rf not yield an error?

ubuntu 9.10 if you type rm you get a missing operand error, same thing with rm -r but rm -f yields no error. -f is supposed to be 'force' not 'dispell errors'
1
vote
1answer
154 views

Removing files with strange names [duplicate]

Possible Duplicate: Unix: Files starting with a dash, - Somehow I ended up with a file named "-r". How do I remove it? rm -r doesn't work. I tried 'rm -i `ls -a`' to step through the ...
37
votes
12answers
86k views

How to recover a removed file under Linux?

By accident, I used rm on a file I didn't want to delete. Is there a way that I can get it back under Linux?
52
votes
7answers
33k views

How do I make rm not give an error if a file doesn't exist?

I'm writing a makefile that will clean up some useless files at the end of the compilation. If a target has already been made, it will of course skip that target and the useless file may not be ...
13
votes
5answers
13k views

use rm to remove files and directories recursively

is it possible to use rm to remove files and directories matching a pattern recursively without using other commands?
16
votes
4answers
69k views

undo Linux's rm? [duplicate]

Possible Duplicate: UNDO LINUX Trash Command Hi, Is there any simple way to undo an rm command? The question is purely theoretical; I have NEVER deleted the log of a benchmark queue who ...