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; 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 ; exit 0 } END { if (! c) {exit 1}}' '{}' ';'
The $vawk
variable seems to be empty.
Any idea?
Asked by Nicolas
(419 rep)
Oct 5, 2012, 06:26 PM
Last activity: Feb 11, 2025, 07:47 PM
Last activity: Feb 11, 2025, 07:47 PM