User Tools

Site Tools


awk:awk_commands

This is an old revision of the document!


AWK - AWK Commands

Commands used by AWK can come from two locations:

  • They can be specified on the command line, as used in the above examples.
  • Alternatively they can come from a source file. If such is the case, AWK is alerted to this occurrence by means of the -f option.

Simple Command File

Assuming a file exists with following contents:

awklist
{print $2,$3}
{print $4,$5,"\n"}

Issue the following command:

awk -f awklist /sharewiz/awk/test.txt

which will display something like:

Peter Terence
Roux 45

Virginia Genevive
Roux 45

Felix Devon
Roux 5

David Bruce
Stevenson 48

Bob James
Smith 16

Adam Winter
Ridley 23

Notice that the apostrophes are not used anywhere within the source file or when calling it at the command line.

They are only for use in differentiating the commands on the command line from file names.

awk/awk_commands.1588636576.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki