So today I had to use find + xargs + grep to search for some things in cygwin, since Windows search is like a hunting dog with no sense of smell. Being Windows, there are spaces in file paths left, right, and center. xargs and grep don’t play overly nice with this.
Originally I had:
find . -name *.js | xargs grep Saving
Which didn’t work. grep was looking for weird things which did not exist. Then I found this link with Google,
find + xargs: how do I handle space in the path – comp.unix.shell | Google Groups
which provided a solution:
find . -name *.js -print0 | xargs -0 grep Saving
A friend pointed out that if there are any JavaScript files in the current directory, .js will get expanded by bash and not work too well. Final solution:
find . -name "</strong>.js" -print0 | xargs -0 grep --color=always Saving
Posted by darkhelmet under Linux & Programming & Windows | No Comments »