rm is the command to remove files

learn more… | top users | synonyms

0
votes
1answer
31 views

Remove a folder with the same name as an environment variable

I was messing around with a log4j properties file and accidently made a folder with the following text ${foo} however I also have an environment variable named foo that points to a folder so thus if I ...
1
vote
1answer
30 views

Why does the -v option with rm show entries with a backquote and a normal quote?

When I do rm -v on a set of files, I see the output list of files being deleted with a backquote and a regular quote, eg: rm -v rsl.out.0??? removed `rsl.out.0579' removed `rsl.out.0580' removed ...
4
votes
2answers
229 views

How to quote arguments with xargs

Suppose that I want to delete all files in a folder that are greater than 1 MB. $ find . -size +1M | xargs -0 rm This will not delete files that have space in their names. So I want it to quote all ...
0
votes
3answers
37 views

Cannot prompt user using rm bultin prompt option -i with xargs and find

I am using xargs and rm with find in order to remove files that follow a specific pattern defined by find as follows. touch file find . -name file | xargs rm Everything works fine with the above ...
2
votes
2answers
42 views

find and delete gives false status

I tried to execute delete as per many previous discussions occurred find & delete however my attempts lead to different experience. find . -type d -name "koko" -exec rm -rf {} \; deletes the ...
1
vote
4answers
187 views

How to delete the files in one folder which are more than 60 days old in UNIX?

I know how to delete the files which are more than 60 days old by modification time, but I want to delete files based on a timestamp in the file name. For example, I have the below files for each day ...
1
vote
3answers
52 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
81 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
336 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
61 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
67 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
68 views

Remove parent and sub directory

sample_dir2 `-- sample_dir |-- cambridge | `-- security | |-- annex | `-- parking |-- history.exe |-- markham | |-- annex | |-- building1 | `-- ...
1
vote
1answer
133 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
131 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
27 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
39 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
196 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
19
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
119 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
97 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" ...
28
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
122 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
107 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
144 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
278 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
80 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
53 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 ...
13
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
162 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
78 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
449 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
162 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
121 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
89 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
82 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 ...
30
votes
8answers
4k 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
286 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
191 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
192 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
548 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
622 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 ...
5
votes
2answers
2k 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
96 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
2answers
10k 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
458 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
310 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
9k 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
100 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 ...