rm is the command to remove files

learn more… | top users | synonyms

-3
votes
2answers
63 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
99 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
15 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
308 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
55 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
67 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
39 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
41 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
477 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
84k 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 ...
33
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
36k 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
191 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
51 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 ...
26
votes
5answers
54k 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
2answers
47 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
65 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
36 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
53 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 ...
28
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
334 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 ...
47
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 ...
25
votes
6answers
31k 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
69 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 ...
31
votes
12answers
178k 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
62 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
676 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
20 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
50 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
54 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
114 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 ...
2
votes
1answer
61 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
151 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
29 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
56 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
6k 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 ...
1
vote
3answers
91 views

Preventing deletion of system/shell aliased folders

Is there a way to prevent deletion of system/shell aliased folders? I want these commands to fail. My shell is bash. Such as: $rm -rf . $rm -rf .. $rm -rf ~ $rm -rf *
1
vote
3answers
140 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
29 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 ...
11
votes
3answers
34k views

How to avoid the need to issue “y” several times when removing protected file

I'm looking for a solution to be used as a response to "rm: remove write-protected regular file [x] ?" I was thinking of issuing a character followed by carriage return for several amount of times, ...
5
votes
5answers
404 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
5answers
77 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.
30
votes
5answers
44k 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: rm:...