I often run find
in my code projects when I make a change somewhere and I have to find where it impacts other pieces of code, so I thought about writing a very small script to make this easier, call it blah.sh
:
#!/bin/bash -eu
if [ $# -ne 3 ]; then
echo "Three inputs required"
else
find $1 -name $2 -exec grep -iHn $3 {} \;
fi
The problem is, I get an error when the third argument (the text I'm looking for) contains a space. For example, blah . '*.php' 'foo bar'
returns grep: bar: No such file or directory
for each file grep
tried to explore. I'm sure it's a silly mistake, I'm not really hands on with bash..