rm is the command to remove files

learn more… | top users | synonyms

-3
votes
0answers
26 views

Modifing RM & LS [on hold]

I am new in Linux, is there a way to do the following: Modifying RM command so that a file in a specific folder are not deleted (means making deception) Then Modified LS in such a way that it doesn't ...
45
votes
5answers
2k views

Why is the wild card character * so different between commands zip and rm?

I put together a script to do some file operations for me. I am using the wild card operator * to apply functions to all files of a type, but there is one thing I don't get. I can unzip all files in a ...
0
votes
3answers
50 views

How do I remove a dot dollar no name directory

I have this weird directory in Oracle Linux that I cannot remove, cannot change owner, cannot change group, etc. It seems to be an environment variable that is empty and is named: .$EXTEND Here's ...
3
votes
1answer
40 views

Deleting hardlink with rm -rfv deletes the original?

I was reading up on similar questions on here about what happens when you delete a hardlink to a file and the majority of the answers I was getting were that the hardlink is deleted but the original ...
1
vote
2answers
25 views

How do I remove all files from wtihin a certain directory except for a child directory of that directory?

I’m using bash shell. I have this command to delete all JAR files within a particular directory find ~/.jenkins/jobs/subco/ -name '*.jar' -print0 | xargs -0 -r rm However, I want to modify the ...
70
votes
1answer
7k views

Why does the following script delete itself?

If you create an executable file with the following contents, and run it, it will delete itself. How does this work? #!/bin/rm
5
votes
8answers
642 views

Have rm not report when a file is missing?

I have a bash script that I want to remove files from various directories. Frequently, they won't be there because they weren't generated and that's fine. Is there a way to get the script not to ...
1
vote
1answer
19 views

OSX: Grammarian won't uninstall

Im trying to uninstall an annoying app on my Mac called Grammarian Pro X and the uninstaller doesn't work with my version of OSX 10.11. You can uninstall the main app but there is still bits of the ...
1
vote
2answers
44 views

How to override option in aliased command? [duplicate]

I have a rm aliased: alias rm='rm -i' How can I override the -i option when I want to remove a large number of files and I don't want to confirm each deletion?
2
votes
2answers
51 views

Delete directories that contain a certain file

I want to find all directories that contain a certain file and then delete those directories. With find . -name thatcertainfile -execdir pwd \; I get a list of all the directories I want to delete, ...
2
votes
4answers
100 views

How to delete a tilde (~) folder? [duplicate]

I need to delete a "~" folder in my home directory. I realize now that rm -R ~ is a bad choice. Can I safely use rm -R "~"?
1
vote
1answer
24 views

What happens if rm is stopped half way through prompts?

What happens if there are prompts during an rm -R command asking if the user would like to overwrite, and then some of the prompts are accepted, but halfway through the user aborts the command. Are ...
0
votes
2answers
28 views

Having trouble deleting specific directories within a specific parent directory

I’m using Amazon Linux, bash shell. I’m trying to write a statement that will delete all child directories named “target” within a specific master directory. I would like to write things such that ...
1
vote
4answers
114 views

Dangers of using rm command with variables

I am creating a crontab that compresses 15 minute clips from my security camera into one file (24 Hours Long) and then having the clips delete. avimerge -o /media/jmartin/Cams/video/Full_$(date +%F ...
0
votes
0answers
35 views

Input/output error when trying to remove a file in NFS

I am trying to remove a file that is located on an NFS storage device. rm model_parameters_epoch_000.npz I get the error message: rm: cannot remove ‘model_parameters_epoch_000.npz’: Input/output ...
1
vote
3answers
128 views

rm prompt when deleting unwritable files

This is about GNU rm. The info page says: Otherwise, if a file is unwritable, standard input is a terminal, and the -f or --force option is not given, or the -i or --interactive=always option is ...
0
votes
1answer
39 views

Can't delete a file

I trie to use sudo rm -rf .Trash-1001 But it says "The Removing of .Trash-1001/info" is not possible: The directory is not empty. (This is a translation by me because I have German as my system ...
1
vote
1answer
28 views

Remove certain types of files except in a folder

I have a command in my makefile for clean: rm -rf */*.o */*.cmo */*.cmi */*.cmx */*.cma */*.cmxa */*.annot Now I would like to write a cleanpartial that removes these files except those in the ...
0
votes
5answers
66 views

Remove the latest modified file

I have created two files: sample.txt and sample.txt  (the second file contains some hidden characters, e.g. a space). How can I remove the latest modified file? I'm using Linux.
5
votes
3answers
613 views

Remove file, but only if it's a symlink

Ideally I'd like a command like this rm --only-if-symlink link-to-file because I have burned myself too many times accidentally deleting the file instead of the symlink pointing to the file. This ...
0
votes
2answers
47 views

Syntax for rm command. Worried about using the -r option

I am trying to create a routine to manage the backup files I am creating, so that older folders will be deleted automatically in the process. Here’s what I've got: #!/bin/sh day=$(date +%m%d%y) ...
3
votes
1answer
62 views

Remove files with match only from some subdirectories

I have a directory with several subdirectories; in each of these, I have some files. I want to perform a grep only for some subdirectories to find those files that match the query and remove them; ...
1
vote
2answers
64 views

`rm` prompt when given more than one file [duplicate]

For some reason, my finger memory has converted mv to rm. Until I manage to retrain those fingers, how might I have rm prompt when provided multiple locations (one of which likely does not exist)? I ...
3
votes
3answers
63 views

How can I remove just the writable files in a directory, without any prompt?

I want to delete only the writable files in a directory. If I do rm * it removes all the writable files (so far so good), but I get a prompt for each non-writable file. I don't want a prompt, I ...
1
vote
3answers
182 views

Cannot remove <file>: No such file or directory

I just ran some self-written program in which I make files and fill them with stuff. However, I did something wrong (or at least, not as intended) with the name generation and now there are four files ...
0
votes
4answers
103 views

Search for and remove files safely

I would like to search for all the nohup.out in my mounted filesystems, and delete them. There are some directories and files whose filenames contain space, so I think of xargs -0. To be safe, I ...
4
votes
1answer
49 views

Is there a tool to create a hard link to an unlinked inode?

Assume you have a filename/directory name, whatever, which is hard linked to inode 6400. Alas, the file/directory actually exists (completely intact, and maybe it only lives in a single data block, ...
4
votes
2answers
150 views

Linux: remove file*..but not file1 and file2 [duplicate]

Usually on bash i did shopt -s extglob rm !(filedontwantremove) and remove all files except filedontwantremove But if i want to remove all file except filedontwantremove and ...
2
votes
3answers
154 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
32 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
22 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
41 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
177 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
34 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 {} \; ...
5
votes
5answers
329 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
109 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 ...
9
votes
6answers
5k 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
25 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
89 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
71 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
53 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
58 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
76 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
113 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
70 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
542 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
85 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
60 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
51 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 ...