i am trying to print the first argument which i input when calling the program, but it's not working. Any help, please?
#!/bin/bash -f
awk '
BEGIN{
print "argc: "ARGC
print "argv0: "ARGV[0]
print "argv1: "ARGV[1]
}
'
run using: ./progName.awk "data"
but 'data' is not being displayed.
Change the last line to be:
' "$@"
Right now you aren't passing any args to awk.
Unrelated and will not change any functionality but change the name of your script from ./progName.awk
to ./progName.sh
or similar as it is NOT an awk script, it is a shell script which just happens to call awk to execute an awk script. You could replace the awk script with perl or ruby or whatever and it would not change the fact that what you have is an executable shell script.