Here is my script (to find the files that contain a specified pattern) :
find . -type f -exec awk -v vawk="$1" '/'"$vawk"'/ {c++} c>0 {print ARGV[1] ; exit 0 } END { if (! c) {exit 1}}' \{\} \;
I would like to use my script with an argument :
MyScript.sh pattern
My problem is that I don't manage to put the $1 variable in awk.
When I try to debug my script
bash -x MyScript.sh pattern
Here is the output :
+ find . -type f -exec awk -v vawk=pattern '// {c++} c>0 {print ARGV[1] ; exit 0 } END { if (! c) {exit 1}}' '{}' ';'
The $vawk variable seems to be empty.
Any idea ?