1

I would like to delete all files that contains " (2)" --whitout the quotes-- in the file names. I tried first with ls to test

ls *(2)*

and list all the files in the folder

ls "*(2)*" 

don't list any file, how I have to format the wildcard to do the right thing?

Thanks

Leosar
  • 113
  • 6

1 Answers1

4

You need to escape (or quote) the parentheses - but not the glob wildcards * e.g.

ls *\(2\)*

or

ls *"(2)"*

or even

ls *'('2')'*

If you want to match the leading space explicitly, you will need to escape or quote that as well e.g.

ls *\ \(2\)*

or

ls *' (2)'*
steeldriver
  • 136,215
  • 21
  • 243
  • 336