I wanted to make a little script to save me some typing, but unfortunately I get no output:
#!/bin/bash
grep -Hnr \"$1\" --include \"*cpp\" --include \"*h\" $2
I played quite a lot with echo and different use of quotes, and convinced myself that line really expands into what I want, but the only way I could actually get any output is with this:
#!/bin/bash
GREP="grep -Hnr \"$1\" --include \"*cpp\" --include \"*h\" $2"
echo $GREP | bash
An example usage would be:
srcgrep "dynamic_cast" src
I’ve tried this in a simple example directory to rule out anything weird with links, permissions, etc.
So, of course I can just use the second, but any idea what’s wrong in the first case? Thanks.
$ grep -V
grep (GNU grep) 2.5.1
...
$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
...
Why not just:
?