rm is the command to remove files

learn more… | top users | synonyms

5
votes
2answers
6k views

how can I recursively delete empty directories in my home directory? [duplicate]

Possible Duplicate: How to remove all empty directories in a subtree? I create directories very often, scattered over my home directory, and I find it very hard to locate and delete them. ...
8
votes
2answers
9k views

Locate and delete all temporary files in user directory

I use vim a lot, and my area has power failure a lot. So the resultant is I get many *.swp files scattered over my PC. I want an alias of rm command that removes all files with either .swp, ~, ...
7
votes
1answer
48k views

How do I remove a directory and all its subdirectories?

I'm trying to learn some directory navigagtion with bash and all I know is that rmdir directoryname will remove the directory but not if it's containing something. Is there a way to force it to ...
5
votes
2answers
11k views

Rm can't delete file

chmod 777 -R /mnt rm -rf /mnt/* rm: cannot remove 'omitted': Read-only file system rm: cannot remove 'omitted': Read-only file system Please show me how I can do this?
13
votes
4answers
4k views

Make `rm` move to trash

Is there a Linux script / application which, instead of deleting files, moves them to a special “trash” location? I’d like this as a replacement for rm (maybe even aliasing the latter; there are pros ...
4
votes
3answers
18k views

How can I delete all files with a particular extension in a particular folder?

If I set the current/working directory (navigating to it using cd) to some particular directory and then type: rm *.xvg What will this command do? Is it true that the above command will only delete ...
1
vote
4answers
3k views

Remove directory in ftp

This is probably very simple, but I really can't get it to work. I have an old directory with a symlink in it. I need to delete the directory, but it says it is not empty when I try: rm -f dirname ...
0
votes
1answer
601 views

OSX : rmdir “permission denied” but directory removed

This is a question from a newbie trying to learn UNIX commands. I was trying to test the rmdir command by removing a test directory located in my Downloads directory. I have read and write rights on ...
12
votes
3answers
6k views

How can I remove all symbolic links with a special target?

With the command: ls -la * I can list all my symbolic links. How can I remove all symbolic links which are linked to a special folder? For example: In my directory usr/local/bin I have the ...
4
votes
3answers
407 views

Need to delete a directory with name '~' created accidentally

I don't remember exactly how this directory got created. It's name is ~, the alternative we all use for home diretory. I also see a sticky bit attached with this directory. How shall I delete it? I ...
2
votes
5answers
3k views

Unable to delete directory

On my OS X host, I am having trouble deleting the directory "foo". mymac:.Trashes joe$ ls foo mymac:.Trashes joe$ ls foo/ Ảnh011.jpg Ảnh012.jpg Ảnh013.jpg mymac:.Trashes joe$ ls -l foo/ ls: ...
8
votes
4answers
5k views

Remove files older than 5 days in UNIX (date in file name, not timestamp)

I want to delete log files which are older than 5 days from a directory. But deletion should not be based on the timestamp of file. It should be based on the name of file. For Example todays date is ...
4
votes
1answer
1k views

Deleting files by age

Is there a command to delete all the files in a directory that haven't been modified in N days? I need to clean up some old logs.
24
votes
12answers
31k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
6
votes
3answers
575 views

What's the purpose of `rm -P`?

I was reading the man page for rm when I came across this option: -P Overwrite regular files before deleting them. Files are overwritten three times, first with the byte pattern 0xff, then ...
5
votes
2answers
844 views

Protect files from `rm -f`

Much to my immediate chagrin, removing write permission from a file does not seem to protect it from rm -f: touch foo chmod a-w foo rm -f foo How can I protect a file from accidental deletion when ...
2
votes
1answer
3k views

How can I delete a hidden folder?

I want to delete many configuration folder in my home user folder but I can't figure out how to delete them. How can I delete a hidden folder?
5
votes
3answers
2k views

Remove many many many files from a folder

I have a folder with 137795 files in it. I need to delete all of them. When I run rm * I get -bash: /bin/rm: Argument list too long. How do I get past this error?
1
vote
3answers
3k views

What is wrong with this “find all vim swap files and remove them with a confirmation” command?

I am trying to remove all vim swap file *.swp and remove them with a confirmation. The find command found the files, but rm says No such file or directory with the -i option. When I hardcode the path ...
5
votes
2answers
279 views

Is it safe to remove a script file from within that script?

Imagine I have a script foo. It should be run once when the user logs in and isn't needed after a successful run. My question: Is it safe to remove the script file from within the script? E.g.: ...
5
votes
1answer
3k views

mv file without write permission to the source file

I just realised that I can move a file that I do not own and don't have write permissions on. I have write permissions to the directory, so I am guessing that is why I could move it, but in this ...
12
votes
1answer
8k views

Unable to delete file, even when running as root

I am in the process of migrating a machine from RHEL 4 to 5. Rather than actually do an upgrade we have created a new VM (both machines are in a cloud) and I am in the process of copying across data ...
3
votes
2answers
408 views

Capturing new output after deleting the output file

I'm runnig a java server on Debian with this command: java -jar myapp.jar [args] >> log.txt Once I gzipped the log file to send it and then I realized the original file was gone, leaving me ...
22
votes
9answers
5k views

How can I delete a file with no name

I somehow managed to create a file that doesn't seem to have a filename. I found some information regarding how to get more details of the file in the following thread. However, I tried some of the ...
4
votes
3answers
2k views

Delete everything except a few extensions

Can I modify the rm command with regular expression or something to delete every file in current directory except files with extensions *.bmp, *.wav and *.png? It should be case insensitive because ...
16
votes
7answers
14k views

How do I recursively shred an entire directory tree?

I have a directory tree that I would like to shred with the Linux 'shred' utility. Unfortunately, shred has no -R option for recursive shredding. How can I shred an entire directory tree ...
3
votes
4answers
1k views

Accidental deletion of /lib directory in Fedora 15

I accidentally deleted the /lib directory on my Fedora 15 machine and I'm not sure how to go about fixing this. Any help in figuring out how to restore the directory along with symbolic links would be ...
10
votes
1answer
2k views

What are the .Trash-500 and .Trash-1000 directories?

I have a DNS-321 NAS drive which apparently runs Linux, so I logged in via ssh and I see .Trash-500 and .Trash-1000 directories. I realize that they're for trash, but why do I need two? Inside of them ...
1
vote
3answers
2k views

Removing a directory hangs

I'm a non-root user on a shared compile server that mounts /home via NFS from some other host. I have a directory ~/a/b with lots of subdirectories c1,c2,.... I wanted to delete ~/a/b completely, and ...
1
vote
3answers
2k views

shell commands to check & create dir

I am writing a Ruby script inside which I would like to invoke/execute some shell commands. The shell commands I would like to run should check if a directory named 'tmp' under /var/lib/mysql/ exists ...
7
votes
2answers
759 views

Remove accidentally extracted files [duplicate]

Possible Duplicate: How to de-unzip, de-tar -xvf — de-unarchive in a messy folder? This is a pretty annoying occurrence. Sometimes, I download an archive (tar.gz, tar.bz2, zip, rar, ...
8
votes
6answers
1k views

Remove empty directory trees (removing as many directories as possible but no files)

Suppose I have a dir tree like this: ROOTDIR └--SUBDIR1 └----SUBDIR2 └----SUBDIR3 I am looking for a command such that when I input: $ [unknown command] ROOTDIR The whole ...
4
votes
3answers
836 views

Delete matching file from every subfolder of current dir

I used this one to copy file in every dir: find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess Now i need to do reverse one and delete file with matching name from every sub directory of ...
10
votes
4answers
15k views

How do I recursively delete directories with wildcard?

I am working through SSH on a WD My Book World Edition. Basically I would like to start at a particular directory level, and recursively remove all sub-directories matching .Apple* - how would I go ...
0
votes
1answer
739 views

What exactly does rmdir -p do?

-p, --parents remove DIRECTORY and its ancestors; e.g., rmdir -p a/b/c' is similar tormdir a/b/c a/b a' Yeah - I'm definitely not going to risk testing that out myself. ;)
5
votes
2answers
1k views

Why doesn't “rm *” work when there are files that begin with a hyphen?

from: http://seclists.org/fulldisclosure/2011/Sep/190 [USER@MACHINE ~] mkdir ejha [USER@MACHINE ~] cd ejha/ [USER@MACHINE ~/ejha] touch ize [USER@MACHINE ~/ejha] touch -- -f -i [USER@MACHINE ...
3
votes
1answer
948 views

Prevent a subdirectory from getting deleted / enforce a directory structure

imagine the following folder structure ../documents ../documents/templates I have two user groups: editors managers Users of both groups should be able to create new files modify any ...
17
votes
3answers
7k views

Is there any way to prevent deletion of certain files from user owned directory?

Let's say user has Directory1 and it contains File1 File2 CantBeDeletedFile How to make so the user would never be allowed to delete the CantBeDeletedFile? If I change the ownership of Directory1 and ...
13
votes
3answers
5k views

How far can you go with rm -rf / as root

If you are root, and you issue rm -rf / Then how far can the command go? Can you recover data from this kind of an action? Even after the binaries are gone, would the running processes still be ...
3
votes
3answers
1k views

How to disable the trash can in KDE

From what I gather, the idea of a "trash can" is of Windows descent, and was to make a user's life easier. However, when I go to delete a file, I don't hit delete unless I know I don't need it and ...
11
votes
4answers
1k views

Accidentally executed sudo rm /* on a remote server

I accidentally executed rm /* while logged in as root in a remote Ubuntu Server and deleted pretty much all binaries and currently I can neither log in via ssh or ftp to restore the files (and hope ...
5
votes
3answers
733 views

Recursively Remove SVN files

I'm still learning the bash shell. I want to recursively find and remove svn files within the child directories of a given folder. I made the mistake of checking out instead of just cloning. So i'm ...
4
votes
3answers
2k views

Delete files based on year

I need to delete all files in a directory that were created in 2009. What command can I use to do that?
7
votes
3answers
4k views

No space on device when removing a file under OpenSolaris

While trying to mount a NFS share (exported from an OpenIndiana server) on a client box, the OI server crashed. I got the black screen of death, what looked like a log dump, then the system restated. ...
2
votes
3answers
1k views

Shift+delete vs rm -rf

Are Shift+Delete and rm -rf different? Is it possible to recover deleted data after performing either of them?
2
votes
1answer
270 views

rm command returns a message [1] 12345 What does this mean?

I'm trying to remove a file and I keep getting a message similar to: [1] 12345 and nothing happens, I run a directory search (dir) and the file remains and I get a stopped message
4
votes
1answer
2k views

deleting a 'file' under /proc or /dev

I am using a cowdancer/debootstrap setup to generate a chroot. Of course, as I iterate, I generate some chroot configurations that are bad. I have found myself in an awkward situation where I have ...
5
votes
5answers
497 views

How do I remove a file I accidentally created named $file?

I was working on a shell script and I accidentally created a file with the variable as its name. Now I have $file in my ls output, and cannot remove it. What can I do?
2
votes
2answers
1k views

How to remove the directory a symbolic link links to plus the symbolic link?

Say a is a symbolic link to b. I am looking for a simple command to remove both a and b at once that does not require me to know about b.
2
votes
3answers
1k views

Delete files if contents do not match pattern

There are hundreds of .html files in a directory. I need to delete files that don't contain word bluecar in their contents. I thought sed with rm would do that, but I don't know how to combine them.