0

Using the following AWK program:

#!/usr/bin/awk -f

BEGIN { FS=":" }

NR==1 { next; }
/^[1]/ { print $0; count++; }

END { printf("%d lines identified. File processing complete", count) }

I am attempting to pass data to the script in the following manner:

cat bio.data | bio.awk

Unfortunately, the shell responds with "bio.awk: command not found"

I used chmod +x on the bio.awk file prior to issuing the command.

Thank you.

CaitlinG
  • 1,955
  • 3
  • 25
  • 35

1 Answers1

3

Simple example of using GNU AWK program from file, let counter.awk be

#!/usr/bin/awk -f
END{print "Processed",NR,"lines"}

and numbers.csv be

1,one
2,two
3,three

then

awk --file counter.awk numbers.csv

output

Processed 3 lines

Explanation: --file counter.awk inform GNU AWK to use what is inside counter.awk rather than first nonoption argument as source. If you want to know more about --file read Command-Line Options in GNU AWK documentation. Note that this solution does not require x permission on counter.awk

(tested in GNU Awk 5.0.1)

Daweo
  • 31,313
  • 3
  • 12
  • 25