rm is the command to remove files

learn more… | top users | synonyms

1
vote
2answers
11 views

how to use alias like this ( alias 'rm -rf'='rm -rfi' )?

I want to get some prompt to make sure when I use command "rm -rf" to delete some file ,so I add alias 'rm -rf'='rm -rfi' to .bashrc profile but it doesn't work ~ thank you very much
3
votes
2answers
2k views

Why can't I delete this file as root?

I have directory exam with 2 files in it. I need to delete files but permission is denied. Even rm -rf command can't delete these files. I logged in as a root user.
4
votes
4answers
146 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
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 ...
4
votes
2answers
2k views

Delete all files except in a certain subdirectory with find

I want to recursively delete all files not accessed in a while in folder a, except all files in the subfolder b. find a \( -name b -prune \) -o -type f -delete However, I get an error message: ...
10
votes
3answers
4k 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 ...
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 {} \; ...
16
votes
5answers
31k 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 ...
33
votes
1answer
3k 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 ...
30
votes
3answers
37k 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 ...
3
votes
1answer
9k views

I can't seem to remove a file even after changing ownership and permissions [duplicate]

Haven't been here much. Mostly Stackoverflow. Anyway, I have a file that I can't remove. I tried sudo rm files.db and got Operation not permitted Did sudo chown me: files.db Then sudo chmod 777 ...
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 ...
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 ...
27
votes
10answers
138k 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 ...
0
votes
2answers
76 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 ...
1
vote
0answers
22 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
67 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 ...
20
votes
6answers
27k 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 ...
14
votes
7answers
10k 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 ...
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 ...
4
votes
4answers
519 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 ...
1
vote
3answers
6k 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 ...
31
votes
2answers
11k views

How do you run a dry run of rm to see what files will be deleted?

I want to see what files will be deleted when performing an rm in linux. Most commands seem to have a dry run option to show just such information, but I can't seem to find such an option for rm. Is ...
38
votes
2answers
292k views

How do I remove a directory and all its contents?

In bash all I know is that rmdir directoryname will remove the directory but only if it's empty. Is there a way to force remove subdirectories?
7
votes
3answers
22k views

Delete files older than X days +

I have found the command to delete files older than 5 days in a folder find /path/to/files* -mtime +5 -exec rm {} \; But how do I also do this for subdirectories in that folder?
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 ...
34
votes
4answers
14k views

How to remove all empty directories in a subtree?

How can I remove all empty directories in a subtree? I used something like find . -type d -exec rmdir {} 2>/dev/null \; but I needs to be run multiple times in order to remove directories ...
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
94 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
49 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 ...
2
votes
1answer
637 views

How to remove all but last 10 files [duplicate]

I accumulate sequentially named files as the result of an automated process, and I would like to keep only the last 10 around. I tried this, which had the effect of deleting everything: ls -r | more ...
3
votes
3answers
432 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 | ...
24
votes
5answers
35k views

rm -rf all files and all hidden files without . & .. error

rm -rf /some/path/* deletes all non-hidden files in that dir (and subdirs). rm -rf /some/path/.* deletes all hidden files in that dir (but not subdirs) and also gives the following error/warning: ...
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 ...
0
votes
1answer
231 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 ...
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 ...
4
votes
4answers
327 views

Remove a directory from inside using the command line interface [duplicate]

Imaging the next simple file structure within the /home/user/ directory: /home/user |--dir0 |--dir1 |--file1 My current directory is 'dir1' and I remove the ...
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) ...
0
votes
1answer
65 views

“find” function still prints files I've already removed

I've removed some directories and files inside them using sudo rm and sudo rmdir, but when I execute sudo find /*/*/ng* the files I've previously deleted are still showing up. Does anybody know why ...
4
votes
4answers
131 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 ...
7
votes
5answers
417 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
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 ...
19
votes
5answers
41k 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 ...
0
votes
0answers
87 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 ...