AWK tutorial: three ways of awk execution

Linux awk command execution ways:

1. Command line execution

➜ awk -F" " '{print $2}' test.txt
linux awk command line exec

Detailed introduction of syntax, see 《Linux awk

2. Shell script file execution

➜ vim test1.awk

#!/usr/bin/awk -f
        print $2

➜ ./test1.awk  test.txt
linux awk shell script exec


The first line of #!/usr/bin/awk is the awk command location.

use : ➜ which awk /usr/bin/awk

3. Awk script file execution

➜ vim test.awk
{print $2}

➜  awk -f test.awk test.txt
linux awk script file exec

Add a Comment

Your email address will not be published. Required fields are marked *