rm is the command to remove files

learn more… | top users | synonyms

5
votes
3answers
2k views

Delete files and directories by their names. No such file or directory

I need to delete all compiled data: directories called build, directories called obj, *.so files. I wrote a command find \( -name build -o -name obj -o -name *.so \) -exec rm -rf {} \; that ...
121
votes
5answers
22k views

I deleted /bin/rm. How do I recover it?

Just for fun, I thought I would use this command on my Raspberry PI running Raspbian: sudo rm -f /bin/rm I thought I could just reinstall coreutils: I was wrong! apt-get install --reinstall ...
-1
votes
4answers
95 views

Using 'find' to create text file, and later deleting files listed

I'm trying to use find to create a text file with the result. And then later be able to delete files, based on that list. I'm using find /volume1/video/ -iname "sample" to give me the results. How do ...
1
vote
0answers
28 views

How to recover deleted directories “/home/pi” [duplicate]

I just deleted my /home/pi directory while I was trying to remove the directory under /home/pi which was /home/pi/nmap. So, is there anyway to recover /home/pi directory as I have other important ...
1
vote
1answer
82 views

rm -f files starting with a digit

I've accidentally redirected the output of a CSV file to my directory. How can I rm only the files that start with a number, and leave the files that start with a letter intact? mymachine$ ls 71.24 ...
1
vote
1answer
66 views

rm -r * in unix [duplicate]

I am about to enter the command: rm -r * in a directory where I would like all files and directories (and their files) removed. My concern is that unix also has the ./ and the ../ directories. rm -r ...
2
votes
2answers
342 views

delete directory with special character in filename

I have these tricky directories that I can't figure out how to delete. If I run ls -ld * I get… drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263 drwxrwx--- 4 user2 ...
4
votes
4answers
330 views

Keeping the number of files in the folder constant by deleting old files

I'm trying to create a script and run it in crontab every 5 min, so that the number of files in a folder always remain 50000. If there are more, I want the script to delete the old files. ...
1
vote
2answers
112 views

Keeping the latest two version and delete the remaining

I have a list of files (say xsl format below) in one directory. I want to keep the last two version of all files. (I can delete the remaing files) {A}_1.0.xsl {A}_2.0.xsl {A}_3.0.xsl {A}_4.1.xsl ...
2
votes
2answers
67 views

Process each line from text file and delete related files from disk

I used the find command to find several files and folders and output them to a text file like so: nohup find /oradba -name '*soapr*' 2>/dev/null >find_soapr_db40.txt & So instead of ...
3
votes
2answers
631 views

grep string from contents of file command then delete file

I have a peculiar problem I need help with. I have a large batch of .docx files where a certain number of them are junk. I know how to identify these files from the file command, as they contain the ...
0
votes
1answer
693 views

Delete all 'nohup.out' within a directory recursively

How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.
1
vote
3answers
65 views

Preventing deletion of system/shell aliased folders

Is there a way to prevent deletion of system/shell aliased folders? I want these commands to fail. My shell is bash. Such as: $rm -rf . $rm -rf .. $rm -rf ~ $rm -rf *
3
votes
3answers
2k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
4
votes
2answers
1k views

Why is rm slow?

I have been trying to use rsnapshot for making backups, but I'm finding it unusable. While it is able to diff a directory (50gb) and duplicate it (hardlinking every file) in a few minutes, and I can ...
6
votes
2answers
428 views

Delete files specified by the output of find: rm thinks argument list is too long.

When I run the following command, it gives me an error: $ rm -f `find /home/domain/imap/domain.com/*/Maildir -mtime +190 | grep -E '/cur/|/new/'` -bash: /bin/rm: Argument list too long How can I ...
1
vote
1answer
1k views

Does rm -rf * delete files recursively from the current directory or parent/root directory?

I wanted to delete files and folder recursively from a particular folder so I ran this command from that folder rm -rf * I assumed it would delete all files/directories under the current directory ...
-1
votes
3answers
2k views

How do I override rw-r--r— root/wheel for a all files in a directory?

I am trying to delete a directory on OS X. I do rm -r /path/dir but I keep getting many, many messages like this: override rw-r--r-- root/wheel for cron/migrate.php? I type y for one message, ...
8
votes
1answer
1k views

Can rm recursively remove empty directories?

In an old version of Unix, the rm command would delete directories if they were empty. From the Research Unix Eighth Edition man page for rm: "If an entry is a directory it is removed only if empty." ...
3
votes
2answers
270 views

Removed `rm` command in cygwin

Having the need to use a bash shell on a Windows computer (I'll spare you the details), I installed Cygwin, and a friend as a joke ran rm /usr/bin/rm on the terminal, and surprisingly nothing much ...
3
votes
2answers
88 views

Guess complete filename

I have some files with really long names lying around on my server and writing the complete names is kind of a pita so I'm asking if my Linux system (Debian 7) can guess the complete filename? I want ...
1
vote
3answers
223 views

AIX 'rm' command has no '-v' parameter for verbose output

AIX 'rm' command has no '-v' parameter for verbose output as stated by IBM's documentation. Normally I would run (in linux) rm -rfv <myfile> to (r)ecursively and (f)orcably delete files and ...
2
votes
3answers
165 views

Remove all files except for last file of each month

Consider a directory with MySQL backup files with timestamps as part of the filename: -rw-rw-r-- 1 ubuntu ubuntu 35856184 Nov 16 16:00 db_2013-11-16_1600.sql -rw-rw-r-- 1 ubuntu ubuntu 35856915 Nov ...
2
votes
2answers
73 views

Proper escape sequence for a non-standard file name [duplicate]

I'm trying to remove a file I made by mistake using --exclude with tar. I ended up making a tar file named --exclude=*.tar Now I want to delete it but I'd like to rename it first. How do I escape it ...
1
vote
3answers
907 views

Remove all *.mp4 and *.zip but some files

In one of my programs I call a bash command to remove all files in the directory, but some: bash -c shopt -s extglob shopt -s nullglob rm /path/to/directory/!("file1" | "file2") Which for what I ...
5
votes
2answers
24k views

How to recover files I deleted now by running rm *? [duplicate]

By mistake I ran rm * on the current directory where I created many c program files. I had been working on these since morning. Now I can't take out again the time that I spent since morning on ...
3
votes
1answer
167 views

How can there be a directory named `~`?

I was trying to test out this buggy/new tool to see how it works, and it prompted me to choose a directory to use for stuff I am doing. From the directory ~/Code/indep, I typed in ...
3
votes
2answers
657 views

What is a regular file?

$ rm foobar rm: remove regular file `foobar'? What does it mean for a file to be "regular" and why does rm treat such a file as a special case?
0
votes
1answer
120 views

rm -rf /home/ Recovery [duplicate]

OS :-Suse Linux Enterprise 12.0 File System :- ext3 I hit rm -rf /home/, immediately I did Contol+C so the command got canceled but until that time I lost ~9GB of data from this /home dir. I don't ...
0
votes
1answer
182 views

rm -rf on vhosts directory, what should I do?

I was tired and unfortunately I did: rm -rf * /var/www/vhosts repertory on my CentOS 6.3 running with Parallel Plesk. I lost many websites, but worst: I've lost chroot, default, fs and fs-passwd. ...
10
votes
1answer
292 views

Is `rm -rf` not atomic?

I've just caught a confusing error: rm: cannot remove `xxx/app/cache/prod': Directory not empty which was caused by the following command: rm -rf $cache_dir/* where $cache_dir is defined as ...
5
votes
5answers
3k views

Faster way to delete large number of files

I have a directory where lots of cached files are getting generated very quickly. Since these are very small files, it is consuming all my inodes very quickly. Currently I am running the following ...
1
vote
2answers
848 views

What's the idea behind rm not removing non-writable file by default?

What's the idea behind rm not removing non-writable file by default? Every time you want to remove a file that is non-writable file for current user but you have a write permission on directory get ...
0
votes
1answer
169 views

when is it safe to remove `/dev/.tmp-block-*` files

i'm currently experimenting with temporary lvm-snapshots (that is: create a snapshot of an LV, do something with the snapshot (e.g. run a backup), then destroy the snapshot. something along the lines: ...
0
votes
1answer
109 views

Proper way to delete contents of directory [duplicate]

What is the proper way to delete all the contents of a directory, without said directory? For example, I have the following directory structure: foo/ bar1/ bar2/ x.txt I want to delete ...
3
votes
2answers
3k views

Scripting `rm` and `rm -i`

I want to create a script that whenever there are more than three files being removed, it invokes rm -i by default. I know it will go in initialization files but can't seem to get it working. So far: ...
1
vote
1answer
870 views

mount.cifs not respecting file permissions in Ubuntu 12.04.2 LTS

I am attempting to mount a cifs drive in standard Ubuntu 12.04.2 LTS using the following line in /etc/fstab: //server-name/share-name /mnt/archive cifs ...
28
votes
1answer
1k views

Does 'rm .*' ever delete the parent directory?

The expression .* is expanded by bash to include the current and parent directories: $ ls -la total 2600 drwxrwxrwx 2 terdon terdon 2162688 Sep 10 16:22 . drwxr-xr-x 142 terdon terdon 491520 Sep ...
4
votes
4answers
4k views

How to delete directories based on `find` output?

I issue the following command to find the .svn directories: find . -name ".svn" That gives me the following results: ./toto/.svn ./toto/titi/.svn ./toto/tata/.svn How could I process all these ...
5
votes
3answers
202 views

What's the real point of the -f option on rm?

By reading the GNU coreutils man page for rm, one of the options is -f, which according to the manual, -f, --force ignore nonexistent files and arguments, never prompt Now, I made some ...
0
votes
1answer
2k views

Undo file removed by rm commend on MAC terminal [duplicate]

I unfortunately deleted .bash_profile file from my MAC. Accidentally I typed rm .bash_profile. Now how can I get my file back?
1
vote
2answers
199 views

Delete files that exist in the source with rsync

I have a folder on server "A" called ./delete. I want to delete everything in the folder ./stuff on server "B" that exists in the ./delete folder on server "A". Its like the reverse of rsync. ...
2
votes
2answers
3k views

delete subfolders without deleting parent folder

For this type of dir structure : /config/filegroups/filegroupA/files/fileA1.txt /config/filegroups/filegroupA/files/fileA2.txt /config/filegroups/filegroupB/files/fileB1.txt ...
3
votes
2answers
162 views

Preventing accidental directory deletion. Making an alias that contains options?

I use an alias to prevent me from accidentally deleting files, and I would like to do something similar for directories. For files, I have the following added to my .bashrc: alias rm="rm -i" I ...
1
vote
2answers
1k views

Removing specific files recursively using rm or something simple?

I have a root folder with a text file in it called pairs.txt. Within that root folder are other folders with text files called pairs.txt in them. Is there a simple way to remove them using rm? I ...
1
vote
1answer
547 views

Where is the trash folder in FreeBSD / PCBSD?

I'd like to delete - undelete files using the shell in PCBSD. But... I don't know where the "trash" folder is. Can anyone tell me?
0
votes
1answer
477 views

Find and remove sub-directories without error?

I need to find a way to remove sub-directories from within a particular directory without receiving an error if no sub-directories exist. This command will successfully remove sub-directories if they ...
2
votes
2answers
200 views

What to do after cancelled “rm -rf /usr/” on Arch?

So I just did this on my up-to-date Arch system: [anna@home ~]$ sudo rm -rf /usr/ ^C[anna@home ~]$ ^C [anna@home ~]$ ^C I terminated the rm very quickly. I can't find anything wrong with /usr/ by ...
0
votes
1answer
114 views

rm -r path : how to avoid being asked at each level?

How to avoid being asked at each level if I want to delete that path? I just want to remove everything in a path?
0
votes
3answers
156 views

How to delete directory ' :q!'? [duplicate]

Accidentally, i have got this directory created in my home, drwxr-xr-x 2 ubuntu ubuntu 4.0K 2012-09-06 07:27 :q!/ I want to remove this somehow. I have tried using escape characters in double ...