1

Somehow I must have mistyped a command, because now I have files named --exclude=.xdr and --exclude=.h5 in one of my directories. I want to delete them. Only problem is whenever I do something like:

rm --exclude=*.xdr

it thinks I'm passing an argument to the rm command. I've tried encasing in single and double quotes but it still didn't work. How can I delete these files?

Cheers

user1654183
  • 4,375
  • 6
  • 26
  • 33

3 Answers3

2

Flag interpretation is done based purely on text. Any string that doesn't start with a - is not a flag. The path to a file in the local directory can start with ./ (the . means "current directory").

I'd also recommend reading the man page for rm, as that explicitly lists two different ways of doing exactly this.

  • rm -- --blah
  • rm ./--blah
that other guy
  • 116,971
  • 11
  • 170
  • 194
Vatine
  • 20,782
  • 4
  • 54
  • 70
1
 rm -- "--exclude=.xdr"

Use this command for delete that file

Kalanidhi
  • 4,902
  • 27
  • 42
0

What about using find:

find . -type f -name "--exclude*" -exec rm {} \; -print
mguijarr
  • 7,641
  • 6
  • 45
  • 72