4
votes
3answers
231 views

How to remove a file with name starting with “-r” using cli [duplicate]

I have been creating odd-named files every once in a while, e.g. $ls -rthl $-rw-r--r-- 1 shamil hep 290 Aug 13 11:58 -rf And interestingly it is impossible to remove this file with rm -f -rf I ...
2
votes
2answers
838 views

rm command: remove files with file names containing brackets

I am trying to remove all files in a Windows 7 directory with filenames containing brackets; ( and ): Using MinGW: rm *(*)* I get an error: sh: syntax error near unexpected token '(' I assume ...
2
votes
1answer
183 views

What command sequence can I use to delete directories but not their files?

How do I delete directories but not the files inside them? I have tried the following: rm -di /Users/arthur/Desktop/MyFolder remove /Users/arthur/Desktop/MyFolder? y rm: ...
0
votes
1answer
97 views

How to remove files that start with 2011XXXX

I have a bunch of files i need to delete, they all start with 2011XXXX. How would i delete them. So far i have this command: ls | grep 2011 | xargs rm And it works, but is there a better way to ...
5
votes
3answers
969 views

Why is the dreadful 'rm -rf /' even allowed? [closed]

We all know the destructive power of the following command executed as root: rm -rf / Related questions: How far will you get with a 'rm -rf /' deleting everything: # rm -rf / I fail to ...
0
votes
2answers
75 views

Remove files which have a certain syntax

I have a couple of files which follow this syntax: *_yyyy-mm-dd_hhhmmm.* Example: *_2010-01-01_00h10m.* *_2010-01-01_01h10m.* *_2010-01-01_02h10m.* *_2010-01-01_03h10m.* ... ...
8
votes
1answer
1k views

Remove all files but one with rm

Is there any way to remove all of the files in a directory except for one with a certain filename? For instance, if I had a directory containing the files file1, file2, and dontdelete. Would there be ...
1
vote
1answer
151 views

Removing files with strange names [duplicate]

Possible Duplicate: Unix: Files starting with a dash, - Somehow I ended up with a file named "-r". How do I remove it? rm -r doesn't work. I tried 'rm -i `ls -a`' to step through the ...