1

I am working on a fix for a .bat script and there is a problem with the following line:

forfiles /m *.site /c "grep -i -l \"%1\^|%2\" %CONFIG_PATH%\\@file" > files.temp

For some reason when I run this in the cmd line (subbing values into 1 and 2) it does not do a case-insensitive search. In a previous version of the file the line was different:

grep -i -l "%1\|%2" %CONFIG_PATH%/*.site > %CONFIG_PATH%\files.temp

This version works. I cannot figure out why the second one works but the first does not. Any help would be greatly appreciated.

Thank you!

Lara
  • 516
  • 1
  • 3
  • 9

1 Answers1

2

After a bit more digging I found the issue. The issue is not with grep but with forfiles. All I had to do was add an extra space between grep and -i. This is a known bug with forfiles. The in depth reason is in this thread:

forfiles without cmd /c

Community
  • 1
  • 1
Lara
  • 516
  • 1
  • 3
  • 9
  • I think the most general solution (if there is any) for the `forfiles` "feature" is to put the command name twice, like `forfiles /C "grep grep -i ..."`; the double-space might help in this case, but fails for many others... – aschipfl Dec 15 '15 at 09:40