rm is the command to remove files

learn more… | top users | synonyms

2
votes
3answers
40 views

How to alias rm to always confirm

When I use the command rm -rf, I want to make sure a prompt always appears before deleting a file, so I tried adding this to ~/.bashrc alias 'rm -rf'='rm -rfi' But it doesn't work. How can I fix ...
0
votes
1answer
20 views

How to safely delete a regular directory that contains several btrfs snapshots inside it?

I have a regular directory than contains directly underneath it several btrfs snapshots. Is it safe to do an rm -rf on the parent directory, or do I need to first do a btrfs subvolume delete SUBVOL on ...
1
vote
1answer
19 views

Workaround for missing rm -I option on OSX? [duplicate]

I'd like to do this, on OSX: alias rm="rm -I" In GNU rm, this means that rm will prompt if it's recursive or if it's deleting three or more files, but not if it's just deleting one or two files. ...
0
votes
1answer
31 views

my home directory appears in my download directory

In my Downloads folder when I run ls I see the home directory, and I don't know why, I want to remove it but I am afraid to remove my home folder. Can anyone tell me how I can just remove the home ...
1
vote
1answer
33 views

Is it possible to determine the progress of an rm command?

Using rm -rf LargeDirectory to delete a large directory can take a large amount of time to complete depending on the size of the directory. Is it possible to get a status update or somehow monitor ...
0
votes
1answer
29 views

Deleting a file after X days does not work [duplicate]

Ive tried multiple ways of writing this and im executing the script myself so it isnt the crontab that isnt working. These are examples of what ive tried : find /home/backups -mtime +1 -exec rm {} \; ...
4
votes
4answers
148 views

Rename folder with odd characters

I have a folder on my Mac called "␀␀␀␀HFS+ Private Data". I'm trying to delete it but it contains a bunch of odd characters that are choking unlink, rm and mv, making it difficult to remove it and ...
0
votes
2answers
77 views

In a folder with many files how to do rm on lots of them [duplicate]

I just experimented a bit in linux and ended up getting very many files in one and the same folder. Now when I try to do rm -f folder/*.png I get -bash: /bin/rm: Argument list too long ...
8
votes
6answers
2k views

How do I pipe ls to grep, and delete the files filtered by grep?

I wanted to delete some package in my home file, but the filename was too long (google-chrome-stable_current_i386.deb). So, I decided to use the command ls|grep chrome|rm to pipe the files to grep to ...
1
vote
0answers
23 views

Are the links between the inode and data blocks of a file removed when deleting the file?

Suppose there is only one hard link to a file. When rm the hard link, the inode and data blocks of the file will be marked as unused. But are the links from the inode to the data blocks of the file ...
1
vote
1answer
68 views

How to recursively remove all but list of files?

How can I recursively remove everything in a directory EXCEPT a small list of files to preserve? For example, let's try to remove all files except ones named f2 and f5. # Create a testing ground ...
0
votes
2answers
58 views

how to delete larger file (e.g., 180G) in unix system?

Because of some reasons, my server machines had some too-large files (e.g.,:180G), How can I delete these files quickly?
1
vote
1answer
38 views

How do I combine '-size` and '-exec rm' in find?

When I use this, it works: find /home -name "error_log" -exec rm -rf {} \; But when I try to add a file size limit, it won't remove any files: find /home -size +5000000b -name "error_log" -exec rm ...
1
vote
2answers
55 views

How can I handicap the `rm` command?

I have a really bad history of rming file then regretting it. I've since created a trash command that I'm trying to use more. However, I still have a lot of muscle memory built around rm. Is there ...
1
vote
2answers
63 views

How to delete corrupted directory

While copying music to the sd card of my android phone, the laptop froze so I had to reboot it using sysrq magic. Now any file manager on my Ubuntu or Android shows a directory 0 bytes big, and ...
7
votes
4answers
2k views

How to cancel a rm command?

There are a lot of questions about how to undo a finished rm command. In my case, my rm started asking: "Are you sure you want to delete this file?" And I need to confirm for each one of them. ...
1
vote
4answers
95 views

Find and delete all same files (by name) between 2 directories

I want to find all files in dir1 having corresponding same file names in dir2, and delete them from dir1. For example: dir1: first.txt second.txt dir2: third.txt first.txt So I want to remove from ...
2
votes
2answers
50 views

Find and replace all same files between 2 directories

I want to find all files in dir1 having corresponding same file names in dir2, and replace them with the files from dir2. For example: dir1: first.txt second.txt dir2: third.txt first.txt So I ...
3
votes
3answers
436 views

Delete all files in a folder except the last (most recent) 20 [duplicate]

I want to remove all the files from different directories, and want to keep only latest files 20 files. is this the correct command to do this? ls -t1 /mnt/dwh/ftp/dwh_ftp_cbs/ARLOGS/ | tail -n +22 | ...
2
votes
0answers
60 views

I can't delete a file from EFI System Partition

I'm trying to delete a file since I installed rEFInd instead or Grub, I want to remove Grub or just remove "grubx64.efi" from my ESP, to make it disappear in the rEFInd boot screen. I can mount my ...
2
votes
1answer
47 views

When does “/bin/rm” removes itself while issuing “rm -rfv / ” command?

When files are being deleted after issuing /bin/rm -rfv / command as root, how does rm continue to run even after /bin has been deleted? How does the kernel deal with this file system process?
2
votes
2answers
42 views

How to delete files if a numerical part of their name is greater than a given number?

I've got files like this: cap_20151023T122915_791033959.png cap_20151023T122918_946392456.png cap_20151023T122920_227637228.png cap_20151023T122920_875467456.png and I would like to use the find ...
3
votes
1answer
160 views

Deleting an empty file, why there are so many sys calls ?

Try to create an empty file and strace the operations that are involved to delete it. The list is very long: touch a strace rm a execve("/bin/rm", ["rm", "a"], [/* 20 vars */]) = 0 brk(0) ...
5
votes
0answers
77 views

How to delete a directory with multiple btrfs subvolumes?

My root file system is on a btrfs partition. My /chroot directory has a number of btrfs subvolumes in it which prevent me from deleting it with rm -rf /chroot. In an attempt to delete all the ...
1
vote
1answer
41 views

Remove a dir with files with nonsense file names

I'm trying to remove a dir on an SD card called MOMMA SCRIB. It has a directory Raven that has a ton of nonsense files in it: me@hackerspace-dev-vm /media/me/MOMMA SCRIB/Raven $ ls ls: cannot access ...
4
votes
4answers
132 views

Unable to delete a file whatever I do

So here is my problem I have a pretty strange file that I can't get out of my computer. I tried pretty much everything. First I used software like CleanMyMac, TrashIt, CCleaner etc... None of them ...
0
votes
0answers
89 views

Perl script to delete big directory

This blog gives different ways of deleting Big Directories and their relative times for deleting a directory with 500,000 files. The script using perl is reported to be fastest, which is given by cd ...
0
votes
1answer
233 views

bash: /usr/bin/find: Argument list too long

I have too many files in a folder. I just want my inodes to be get free as soon as possible,So I have tried with find ./EcoBackup/* -name '*.*' > FilesBackupName.txt bash: /usr/bin/find: Argument ...
3
votes
2answers
130 views

Why does deleting directories generate error messages with find -exec?

Why is it that: find . -type d -name test -exec rm -r {} \; generates error messages: find: ./foo/test: No such file or directory find: ./bar/test: No such file or directory find: ./blech/test: No ...
4
votes
2answers
48 views

Tar is currently reading a 2GB file, and I deleted its only link. How do I stop it from running for an eternity?

Some more information: I was backing up a large directory with tar, only there were a couple of large files there that I didn't expect. This connection is over the network and very slow, so simply ...
0
votes
0answers
22 views

What's the equivalent of “rmtrash” on Centos Linux?

On Mac OS X, I use rmtrash package and command to more safely delete files. Is there an equivalent of that on Centos Linux?
0
votes
1answer
65 views

Why can't I `rm -r .`? [duplicate]

A question I already asked myself a few times is why I can't delete the current working directory using rm -r . The shell does not have a problem with a non-existing directory as working directory, ...
1
vote
2answers
57 views

Permissions to remove all files in subdirectory

I have a folder myfolder with lots of files and directories as follows: -rwxrwx--x user1 user1 . -rwxrwx--x root root .. -rw-rw---- user1 user1 file1 -rw-rw---- user1 user1 file2 ...
3
votes
3answers
58 views

removed a vagrant file and now I see .nfs0000000000b869e300000001?

I rm'd a file and now I see: $ l total 64 -rw-rw-r-- 1 502 17229 Sep 17 16:42 page_object_methods.rb drwxrwxr-x 7 502 238 Sep 18 18:41 ../ -rw-rw-r-- 1 502 18437 Sep 18 18:41 ...
1
vote
0answers
82 views

Unable to delete files even with root, lsattr is also not responding

I have two somehow corrupt files in my second hard disk of my laptop, which has dual boot Ubuntu 15.04 and Windows 7. I keep it mounted as a ntfs formatted partition in media. I share this drive ...
2
votes
1answer
45 views

What is the difference between the error “not found” and the error “command not found” are they the same?

In this question the user is getting the error "not found". I realized that the error is "not found" instead of "command not found". Are these two errors different? I'm not sure if I've just never ...
7
votes
5answers
420 views

How to remove a file that start with “>” or other unusual characters [closed]

I've accidentally created a file called > option[value='2016'] How can I delete it? My attempts: $ rm "> option[value='2016']" rm: cannot remove ‘> option[value='2016']’: No such file or ...
1
vote
3answers
88 views

Deleting all files except folders within directory

I am still pretty new to terminal based commands but while I was doing a rsync command between remote and local, I have accidentally 'copied' the files to the wrong place (Eg. /serA/items) instead of ...
1
vote
2answers
139 views

How to remove a file with two words separated by a space in the shell? [duplicate]

I made a text file called hello world in my home directory. Via the shell I am trying to remove it with the rm command. However, when I execute rm hello world the shell thinks that I am trying to ...
-1
votes
1answer
53 views

Remove files and subdirectories of particular folder

I need to remove files and sub-directories in a particular folder but not that folder itself. I am using below command: find . -type d -depth -mtime +7 -exec rm -rf {} \; But it throws following ...
1
vote
1answer
31 views

Detecting file size and do operation conditionally

In my main_dir, I have a lot of sub-folders say DFT1 to DFT150, and in each directory, there is a file named OSZICAR. However, some of this would have file size 0. So I would like to have a script, ...
2
votes
3answers
91 views

How to delete that directory?

I have a directory, that I cannot delete with rmdir. I get always a permission denied error. But when list the directory (with ls -l) I get this: drwxrwxrwx 2 user user 4096 Aug 28 09:34 directory ...
45
votes
2answers
4k views

why is rm allowed to delete a file under ownership of a different user?

From the post Why can rm remove read-only files? I understand that rm just needs write permission on directory to remove the file. But I find it hard to digest the behaviour where we can easily delete ...
-2
votes
3answers
55 views

Delete subdirectory folder while saving contents

Lets say I have the directory /Users/admin/Documents/Folder1/file1.txt and would like to delete Folder1 without also deleting file1.txt. In the end it should look like ...
6
votes
1answer
144 views

How can I delete a file named “--append”? [duplicate]

By mistake I have created a file named : --append. How do I delete it? Simply entering the usual command, rm -f --append, doesn't work.
0
votes
2answers
64 views

Interactively remove files in loop with standard input redirection

I need to interactively (i.e. rm -i) remove files stored in variable $to_remove (one path per line). Unfortunately my code doesn't work because standard input is already used by redirection ...
0
votes
1answer
155 views

Count deleted files with interactive rm (rm -i)

I want to count number of interactively removed files and directories: for f in /tmp/mydir/* ; do rm -ir "$f" done How to do it in most concise/elegant way? Example: abc@def:/tmp/mydir$ tree ...
0
votes
2answers
56 views

rm refuses to remove folder! (nothing to do with the -R option)

I'm using Ubuntu on my personal laptop, and on my system, whenever I use rm on a file, it is gone. for good. The problem is on my university server. I am trying to delete a folder: environment/tests ...
20
votes
3answers
583 views

The precedence of command options?

I know that rm -f file1 will forcefully remove file1 without prompting me. I also know that rm -i file1 will first prompt me before removing file1 Now if you execute rm -if file1, this will also ...
1
vote
1answer
50 views

File/directory not being deleted?

Please see the screenshot. The image on the left says existing x installation found at /opt/x The image on the right shows the terminal where I attempt to delete the same directory. The terminal on ...