I'm a long-time find
and bash
user, but this seems to be the first time I've tried to run a find
command in a script.
I'm trying to loop through all the project source files to find the first argument passed to a few functions. I've written and tested a little awk script that seems to do the job and I can run it from the command line via
find sources -name '*.cpp' -exec awk -f foo.awk {} \;
The trouble comes when I try to put it in a script, via
echo find sources -name *.cpp -exec awk -f foo.awk {} \\\; >foo.sh
so that foo.sh contains
find sources -name *.cpp -exec awk -f foo.awk {} \;
If I now source it into my bash shell via
source foo.sh
I get the error
find: missing argument to `-exec'
I thought that was a quoting issue, so I doubled the backslash before the final semi-colon. It made no difference. Just for laughs, I tried trebling the backslash. Still no difference.
Full disclosure: I'm running on Windows 10, under cygwin, using GNU Awk 5.1.0. I've been writing the scripts by using cat, so I should be clear of any problems with line endings
Update
Except that I don't. Running with a different awk script, the script that I've just pasted into this question works fine. I shall try again tomorrow and post my findings.
Thanks for your forbearance.
I've been writing the scripts by using cat
– Nice. Only two steps to butterflies. :D Just in case: how exactly do you usecat
for this task?