2
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 this is because the rm
command sees a bracket as some sort of special input. What could I do instead?
rm '*(*)*'
gives merm: cannot lstat
()*': No such file or directory.
rm ()*` works (but also wants to delete directories with this match but that's what the original of the OP wants too, giving an error-line). – Rik – 2013-10-08T09:39:49.557Using quotes did not work for me. The escape backslash did though. @Rik - Apologies - I was not specific. The directory I am looking at has no sub-directories. – atomh33ls – 2013-10-08T09:45:47.800
1@RedGrittyBrick The first method only works on the one file named
*(*)*
, but OP wants to work on all files containing(
and)
. Try it yourself with atouch 'a(b)c'
. Thenrm '*(*)*'
does not work on all these files. Also not in bash on Linux! Therm *\(*\)*
does work on both Linux and mingw. – Rik – 2013-10-08T09:57:14.3531@Rik: Thanks, I was aware of that (which is why I mentioned "all metacharacters") - but maybe it is confusing to include that in this answer - I'll remove it. – RedGrittyBrick – 2013-10-08T10:19:38.353