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

learn more… | top users | synonyms

97
votes
11answers
73k 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
1k 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 and ...
0
votes
2answers
3k 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 ...
12
votes
6answers
13k 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 *
7
votes
6answers
12k 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
10k 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?
7
votes
3answers
15k 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 way ...
10
votes
1answer
18k 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
76 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.* ... *_2010-01-01_23h10m.*...
5
votes
2answers
3k views

Delete all 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 ...
4
votes
2answers
5k 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
91 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 via ...
2
votes
4answers
10k 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 ...
10
votes
3answers
10k 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?
9
votes
1answer
2k 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
233 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
449 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 with ...
1
vote
1answer
2k 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 ...
5
votes
5answers
2k 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: %8BUe&#...
0
votes
2answers
859 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
581 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
191 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 file ...
50
votes
13answers
158k 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?
134
votes
9answers
98k 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 there....
17
votes
5answers
18k 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?
25
votes
3answers
118k 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 ...