rm is the command to remove files

learn more… | top users | synonyms

7
votes
3answers
665 views

How can I safely ensure a variable contains only a valid filename?

Given the script below, how can I ensure that the argument only contains a valid filename within /home/charlesingalls/ and not a path (../home/carolineingalls/) or wildcard, etc? I only want the ...
1
vote
2answers
48 views

Unable to delete files through Terminal

More recently, I have been using rm -r /path/to/file to delete files, but when deleting from certain locations, I get the error: override rw-r--r-- root/admin for filename? I have tried entering y, ...
2
votes
2answers
340 views

How to remove a file that can be seen but no program can seem to touch?

I'm trying to remove some obsolete backups, and deep inside one I've found a file 'cifs3bee' that I can find no way of removing. (And since I can't remove it, it's preventing the removal of the entire ...
0
votes
0answers
41 views

Removing directories: Shell vs. File Manager

I've noticed that some graphical file manages such as Thunar allow you to remove any directory as long as you are the owner of this directory -- even if this directory contains a sub directory which ...
30
votes
6answers
57k 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 ...
1
vote
4answers
67 views

How do I delete file by filename that are set as dates?

I want to delete file not by date access or created, but by filename. The filenames will be dates and I want to have a cronjob run once a week that will purge filename dates older than 7 days. I could ...
19
votes
3answers
40k views

How do I remove all sub-directories from within a directory?

This question is kind of a phase II to the first question I posted at here I have a directory that contains a bunch of sub-directories, .zip files, and other random files not contained within a sub-...
1
vote
1answer
45 views

Find case duplicate files and rm uppercase

I have a number of image files that have duplicates across case (ie file.jpg File.jpg). I need a script like the following except I want to completely remove all uppercase. I know that fslint can do ...
0
votes
0answers
17 views

Is it safe to delete '.journal~' files?

Our Apache installation is in /var/www on a CentOS 7.2 virtual machine. On occassion I run the following to ensure there are no unintended backups which could leak information to an attacker: $ sudo ...
-3
votes
2answers
71 views

find all files excluding one directory

so I want to clean a directory before I start work. I looks a bit like this. ./static ├── css │   └── styles ├── img │   └── pictures └── js └── scripts I want to rm the contents of css and js ...
1
vote
1answer
120 views

View list of deleted files

I have executed rm -f *.gz about 30 days ago. Is there any way to find out the list of files that were deleted?
0
votes
1answer
20 views

rm: cannot remove Input/output error in part of folder in a permanently mounted NTFS drive

I was experimenting with HDF5 installation from a permanently mounted NTFS data partition so lots of deletion etc. Now part of the folder (containing some codes etc.) is not deleting and showing the ...
2
votes
1answer
321 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
3answers
59 views

Remove directories sequentially vs. simultaenously in background [duplicate]

Part of a script I am writing utilizes rm -rf to completely remove two directories. These directories are relatively large and can take a considerable amount of time to remove. Currently the ...
-1
votes
1answer
68 views

How to find a dynamic folders?

Hello StackExchangers, I created folder like this : $folder_name=`date "+%Y%m%d"` $mkdir -p ${DIR_LOG}/${folder_name} Example of folders name: [20160622], [20160621]...etc Now I need to find ...
0
votes
1answer
44 views

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

I've tried multiple ways of writing this and I'm executing the script myself so it isn't the crontab that isn't working. These are examples of what I've tried : find /home/backups -mtime +1 -exec rm {...
1
vote
1answer
43 views

How to delete tmp files with messy names?

By mistake, I created a lot of tmp files suffix '.bedgraph' in my working directory. How could I delete them? I tried to use rm -rf *.bedgraph but it did not work. MBD_peak_bedfile N?????A???c??XO....
0
votes
1answer
484 views

rm -rf on vhosts directory, what should I do?

I was tired and unfortunately I did: rm -rf * /var/www/vhosts repertory on my CentOS 6.3 running with Parallel Plesk. I lost many websites, but worst: I've lost chroot, default, fs and fs-passwd. ...
67
votes
12answers
87k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
34
votes
2answers
6k views

Why can't I remove the '.' directory?

I tried removing the '.' directory. I thought I could just delete my working directory without having to go into a parent directory. The point of my question is to look for some insight into how the ...
18
votes
5answers
37k 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 ...
0
votes
2answers
222 views

Why does my command: “rm -rf *” not delete all the files in a directory? [duplicate]

Most of the files are gone, but I'm still left with these two files: ".RData" and ".Rhistory" Why is this the case? I'm working with R, but I don't know what those files are. Afterwards, I can ...
3
votes
1answer
59 views

Removing file and its sym links

If I create a file and symlink to it e.g touch "example" ln -s "example" "link_example" and use rm example the symlink is still there. How can I delete file and all symlinks that points to that ...
2
votes
1answer
82 views

How can I safely recover deleted data from a USB flash drive?

This event actually took place a few years ago, but I still have the unchanged USB flash drive in my possession. I may be out of luck, but I thought I would ask all you smart people here for your ...
1
vote
2answers
54 views

Behavior of rm - how to prevent deletion of mounted points contents

There is a way to prevent rm from deleting mount points? For example, if I have /mnt/backup mounted externally and someone runs rm -rf / I know it will delete the backup contents. My solution is to ...
2
votes
2answers
67 views

how can I find files based on different names and delete all them in one single line [duplicate]

Finding files based on different names I know how to do. The problem is that I don't know how delete all of them at once. I am using OMVS in z/OS390. To find files searching by different extensions I ...
1
vote
0answers
37 views

Delete all the files which has only one line [duplicate]

I have a directory which contains about 9,000 files. I want to delete those files which have only one line. My command is: wc -l * | grep '^ 1 ' | awk '{$1=""; print $0}' | xargs -0 rm ...
0
votes
3answers
54 views

How to remove poorly named file [duplicate]

I was using pscp to copy files from a Windows machine to a Linux machine. I accidentally got the path wrong and now there are files that I can't seem to remove. I think it is because of the slashes in ...
29
votes
13answers
12k views

How can I delete a file with no name

I somehow managed to create a file that doesn't seem to have a filename. I found some information regarding how to get more details of the file in the following thread. However, I tried some of the ...
5
votes
5answers
337 views

How safe it is to output to <dir> simultaneously with rm <dir>/*

Sometimes I need to remove all the contents of a directory and create new files there. Can I do something like this and expect all new files to remain intact: % rm -rf regression/* & ( sleep 10 ; ...
1
vote
0answers
41 views

Simple code reading issue [closed]

I'm studiyng Linux on a guide as a beginner, and there's a code example I cannot understand. I let you it below: find . -name "*.tmp" -exec rm {} \; by reading it, up to now I can understand that ...
48
votes
5answers
3k 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 ...
27
votes
6answers
32k 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 ...
0
votes
3answers
77 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 ...
34
votes
12answers
187k 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 example,...
71
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
3
votes
1answer
53 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
77 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 ...
5
votes
8answers
719 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
21 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
65 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
59 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
129 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
26 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 ...
2
votes
1answer
67 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 ...
1
vote
4answers
202 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
2answers
32 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 ...
0
votes
0answers
82 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 ...
13
votes
4answers
7k views

How can I delete a folder with lots of subfolders fast?

I have a folder with 266778 subfolders. How can I delete it? I have tried cd ~/.local/share/Trash/ sudo rm -rf * but it takes much time. After 1 minute 25 seconds real time and 0.072 seconds user ...
6
votes
2answers
3k 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 ...