Tagged Questions

rm is the command to remove files

learn more… | top users | synonyms

1
vote
3answers
38 views

How to remove matching files from directory A in directory B in the command line?

I have some duplicate files in directories A and B, how could I delete the dupes in B using the filenames from A in bash? How to do it in other shell's is a welcome bonus.
0
votes
1answer
30 views

find - exec rm vs -delete

I'm trying to understand the difference between these two commands: sudo find / -name .DS_Store -delete and sudo find / -name ".DS_Store" -exec rm {} \; I noticed that the execmethod is ...
24
votes
2answers
8k views

I made a mistake last night, which deleted 1800GB of my File-Server unintentionally

I ran this command yesterday, I thought on a test machine, but it was a File-Server connected through SSH. sudo rm -rf /tmp/* !(lost+found) My terminal emulator is Konsole. My system is Debian 7. ...
6
votes
3answers
302 views

how do I remove all files in a folder except just some specified files?

I want to remove all files in a directory while leaving just some specified files, they don't have anything in common by name. How could I achieve that? For example, the file names I want to keep ...
0
votes
1answer
56 views

Why won't OS X let me rename a file?

I accidentally named a file testIn2Post.py rather than testIn2post.py (notice the different case for the letter "p") and have been unable to rename it, even after rm-ing the file in question. Notice ...
1
vote
5answers
58 views

How to delete files, symbolic in one folder, but leave its subdirectories unchanged?

Assume there is a folder that has files, symbolic links, and subdirectories as following: files: file1, file2, file3, file4 symbolic links: link1-->file2, link2-->file3 subdirectories: dir1, ...
1
vote
1answer
62 views

Remove parent and sub directory

sample_dir2 `-- sample_dir |-- cambridge | `-- security | |-- annex | `-- parking |-- history.exe |-- markham | |-- annex | |-- building1 | `-- ...
1
vote
0answers
124 views

File of Doom freezes any computer that attempts interaction

I have a file on an internal server that causes any machine that interacts with it to immediately and irrecoverably freeze. By interaction, I mean just about anything: rm, mv, cp, cat, vi, gedit, ...
2
votes
3answers
109 views

How to remove file with mv command?

I started to study Solaris in my university. Teacher told me to remove a file with mv command. I tried to move a file to /dev/null. But that did not work. How can I remove file with mv command?
1
vote
0answers
25 views

Command that can find files that are not referenced by other files and then delete them

I was wondering if anyone knew how I could go about writing a grep command that recursively finds files that are not being referenced/used in a specific file and/or a directory of files, and then ...
0
votes
1answer
35 views

mount command over existing drive, then deleted

So I had a directory sitting on /dev/sdb1 I umounted the drive, moved the backup to sdc1 and restarted the server, still can't see the files...
2
votes
4answers
189 views

Remove file with ` in name

At some point I created a file with: ` in it. How do I remove it? ls -la returns: -rw-rw-r-- 1 ec2-user ec2-user 0 Sep 25 23:01 `which
20
votes
2answers
1k views

How does rm -r go about recursively removing? In what order?

Is there some order of operations to rm? I performed rm on a large directory and am curious where I should look to see what might have been deleted. Does rm work on files first, then directories? Or ...
0
votes
3answers
99 views

Unable to delete a file without permissions etc

I have a file in Windows XP left over after deleting Google Chrome. Its location is C:\Documents and Settings\Admin\Local Settings\Application Data\Google\Chrome\User Data\Default\old_Cache_000 The ...
0
votes
1answer
75 views

How do I delete directory and file, if .picasa.ini is the only file in the directory?

I want to start from a root directory and recurse through the tree. I want to delete the directory and file if there is only one file in the directory called .picasa.ini It seems like the "find" ...
29
votes
2answers
1k views

Why did powering down my machine after a bad `rm` save my files?

Classical situation: I ran a bad rm and realized immediately afterwards that I had removed the wrong files. (Nothing critical and I had tolerably recent backups, but still annoying.) Knowing that ...
0
votes
1answer
100 views

Accidentally rm -r the wrong etc folder… Help? [duplicate]

Well as you can see from the title I managed to accidentally rm -r the wrong etc file in Ubuntu 14.0.4 Desktop. I also decided I would set up encryption on my home folder (Another mistake). Is there ...
0
votes
1answer
83 views

Delete empty directories using 'ls' command

I want to delete empty directories without using find command find . -empty -type d -delete. like the following: if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi How do I ...
1
vote
2answers
129 views

Delete old files but keep one each week/month/year

I have a folder with log-files each ~10 minutes: alfred_140810-190001.json alfred_140810-191001.json alfred_140810-192002.json alfred_140810-193001.json alfred_140810-194001.json ...
-1
votes
1answer
185 views

What does /bin/rm -f <file> do in Unix?

I came across a line and had no idea what it does. I have also checked Google, but still no luck. $ /bin/rm -f fslvbm2a There is no output on the screen.
1
vote
3answers
78 views

How do I delete a folder but not the contents?

My directory (in Linux) looks like com/com/{various,files} where com and com are folders of the same name and the second com holds the various files. I want the first com removed, but the second and ...
0
votes
0answers
48 views

How to remove files except a list with names files [duplicate]

I need delete some .desktop files in various directories and a text file with a list of file names. I want to delete all these .desktop files except for those listed in my text file). Example $ ls ...
12
votes
2answers
1k views

What is the difference between 'rm' and 'unlink'?

Assuming you know the target is a symbolic link and not a file, is there any difference between using rm and unlink to remove the link?
7
votes
1answer
139 views

Why are rmdir and unlink two separate system calls?

Here's something that kept me wondering for a while: [15:40:50][/tmp]$ mkdir a [15:40:52][/tmp]$ strace rmdir a execve("/usr/bin/rmdir", ["rmdir", "a"], [/* 78 vars */]) = 0 brk(0) ...
-2
votes
2answers
71 views

Getting a propmt when deleteing a non-directory

I want to get a prompt when attempting to delete a non-empty directory with rmdir. Is this possible?
3
votes
2answers
322 views

Deleted /tmp accidently

Accidently, I ran sudo rm -r /tmp, is that a problem ? I recreated it using sudo mkdir /tmp, does that fix the problem ? After I recreated the directory, In the places section in the sidebar in ...
3
votes
2answers
110 views

Cannot delete File on Fedora

I have a file with following permission: -rwSr-s---. 1 1634630331 1818884080 118784 Jun 29 1970 DailyUpdateClass.class If I try to delete this file with root login, I get error. rm: cannot remove ...
0
votes
1answer
106 views

Delete ghost files with special characters

I have read several ways to delete files with special characters, but none of them works for me in one special folder in my cache system. I have no idea how the files got there, and why they turned ...
0
votes
1answer
78 views

How do I delete a file in a read-only directory?

I've got a directory and a file in it, with the directory marked as read-only: $ mkdir directoryname $ touch directoryname/filename $ chmod a-w directoryname I cannot delete the file, even if pass ...
3
votes
5answers
81 views

How to find and empty some directories

I'd like to find and delete the contents while leaving the directories themselves intact. The following find /data1 -name MyTargetDir -type d -exec rm -rv {} \; and find /data1 -name ...
29
votes
8answers
3k views

How to delete this undeletable directory?

I untarred a corrupt tar file, and managed to end up with some directory that I can not delete, If I try to delete it, it seems like it can not be found, but ls shows it's present, both with bash and ...
3
votes
2answers
224 views

fdupes - delete files after comparing two directories

I'm currently trying to solve an issue using fdupes. I'd like to compare two folders with each other, and afterwards delete all duplicate files within one of these directories. Example: Files are ...
1
vote
3answers
182 views

Removing a directory that has no files in it

I recently created a username and a group called gamesForAdmin. Since then I deleted it and the folder I made for it is still there: drwxr-xr-x 5 root root 4096 Jul 4 11:28 . drwxr-xr-x ...
2
votes
2answers
157 views

Remove files and directories even if not empty, except some directories

I am trying to remove all contents of a directory with some exclusions. I'm currently using this: find . -type f | grep -vZf ../../exclude.file | xargs rm -rf The exclude.file contains: *log* ...
1
vote
2answers
447 views

du cannot access file - No such file or directory error

I have lots of subfolders inside a particular folder which in turn contains lots of smaller files. They are created programmatically and so I do not know how many of them are there inside. I decided ...
3
votes
1answer
50 views

Is there a single '03 registered UNIX which can't do rm — -foo at this point?

I'm trying to dispel this uncertainty I have about the use of the double-dash (two hyphens, --) as an end of options delimiter(as opposed to a long option prefix). It's possible some confusion arose ...
5
votes
1answer
502 views

Give user permission to rm without password or sudo

I'm trying to give the ubuntu user on my machine the ability to rm folders and files (mainly in the /www/ folder) without the need to invoke a password or the need to use sudo. I've been following ...
4
votes
2answers
1k views

“no such file or directory” message when deleting a file that exists on NTFS

I have a directory with images. Suddenly I found out that there's a new image with a new name. The image content is similar to another image in another directory but with a different name. I didn't ...
1
vote
1answer
83 views

Minimum file permissions to delete a file [duplicate]

To delete a file in Linux: What minimal permissions do we need to set on it? What minimal permissions do we need to set on its parent directory?
4
votes
1answer
7k views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
2
votes
1answer
352 views

Double rm verification in zsh

When I do a rm * in zsh, I get something like this: 2014-06-08 10:14:23 $ rm * zsh: sure you want to delete all the files in /home/assay/assay/log [yn]? y rm: remove regular file `development.log'? y ...
1
vote
3answers
228 views

How to remove all FIFO files with a shell command

I can't find a shell command to remove all the FIFO files inside a directory. In fact, for the removal of directories, the rm command offers the options -d, --dir, but for FIFOs it offers no option. ...
3
votes
1answer
6k views

Does Linux allow executing the “rm -rf / ” command? [closed]

We all know that we have to use the -rf option of rm command carefully. What I wonder is does Linux allow executing this command: rm -rf /? If so, why? This command could have disastrous ...
1
vote
1answer
94 views

Prevent active file removal on an NFS filesystem

I clear my logs using following script - find "." -mtime 1 -type f -print0 | xargs -0 rm -rf But it deletes the active files also and creates .nfsā€¦ files instead. Is there any way to prevent ...
2
votes
0answers
129 views

Why is my inotifywait loop exiting after removing some subdirectories?

i have the following bash script: #!/bin/sh dir1=/source/dir/path/ while inotifywait -qqre modify "$dir1"; do rm -r /destination/dir/path find /source/dir/path/ -name .svn -exec rm -rf '{}' \; ...
2
votes
1answer
2k views

Delete files/ folders with .nfs files

A lot of time when I delete a folder, it says cannot be deleted because of .nfs files Error - Device or resource busy How can I delete a folder ignoring these errors ( is there any flag in rm ...
4
votes
1answer
155 views

Is there a UNIX command to list all recently removed files from a system

Accidentally a rm -rf command was launched to my root directory instead of current directory. I stopped file removing by Ctrl+C but some files has already been removed. Is there a LINUX command to ...
0
votes
1answer
148 views

dd and rm -r commands

For me, the following commands do exactly the same thing: dd if=/dev/zero of=/dev/sd1 dd if=/dev/null of=/dev/sd1 rm -r /dev/sd1/* meaning, the result of their application is the same. Or least, ...
0
votes
0answers
68 views

named.run file deleted but data left on disk?

Today I had a name-server stop resolving DNS due to the /var directory being full from the named.run cache build up. I tried removing all the files using: rm -rf name* However, although running ls ...
0
votes
1answer
67 views

Delete subfolder and keeping up parent folder

I need to delete folderx which are not accessed for seven days, easily I can do it with next: find /path/folder -type d -mtime +7 |xargs rm -rf The probelm is when I have subfolder marked for ...