rm is the command to remove files

learn more… | top users | synonyms

0
votes
1answer
578 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
5k 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
389 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
2k 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
4k 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.
22
votes
12answers
29k 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
554 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
812 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?
4
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
260 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 ...
10
votes
1answer
7k 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
390 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 ...
21
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
1k 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
13k 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
695 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, ...
6
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
811 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 ...
9
votes
4answers
14k 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
684 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
918 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 ...
16
votes
3answers
6k 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 ...
4
votes
3answers
646 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
968 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
255 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
479 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.
5
votes
2answers
1k views

What's the reason that “rm -rf a/b” says “a/b is not empty”?

The following script sometimes gives me things like can't remove a/b as it's not empty ssh -T user@host <<EOF cd somewhere rm -rf a/b EOF But I log in to the server and execute rm -rf ...
10
votes
6answers
29k views

How to remove all the files in a directory?

I am trying to remove all files and subdirectories in a directory. I used rm -r to remove all files, but I want to remove all files and subdirectories, excluding the top directory itself. For ...
12
votes
7answers
5k views

What's the best way to format a HDD in Linux in order to leave no trace?

I'm running Debian and need a way to format the entire hdd in order to not leave any trace on it because I want to donate it to a friend. So what will be the best way in order to format it? If I ...
23
votes
6answers
26k views

Where do files go when the rm command is issued?

Recently I accidentally did rm on a set of files and it got me thinking where exactly these files end up? That is to say, when working with a GUI, deleted files go to the Trash. What's the equivalent ...
6
votes
2answers
9k views

giving grep output to rm

I'm trying to pipe grep output to rm, but it outputs useless stuff. Is any switch required for rm? Or can rm can be provided a regexp directly? ls | grep '^\[Daruchini'| rm rm: missing operand Try ...
4
votes
2answers
717 views

rm -rf failing if deleting in parallel

rm -rf will fail if something tries to delete the same file tree (I think because rm enumerates the files first, then deletes). A simple test: # Terminal 1 for i in `seq 1 1000`; do mkdir -p ...
6
votes
1answer
3k views

I can't remove a directory tree with rm -rf

This seems very strange to me. I'm running kernel 2.6.37.2 and ran: ~]$ cp -r /proc/ here ~]$ rm -rf here I get some permission denies when copying as expected and I eventually hit Control-C. I get ...