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.
- 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.
Assuming a file, test.txt, exists with the following contents:
10 Peter Terence Roux 45 11 Virginia Genevieve Roux 45 12 Felix Devon Roux 5 13 David Bruce Stevenson 48 14 Bob James Smith 16 48 Adam Winter Ridley 23
Simple Command File
Assuming a command file exists with following contents:
- awklist
{print $2,$3} {print $4,$5,"\n"}
Issue the following command:
awk -f awklist test.txt
which will display something like:
Peter Terence Roux 45 Virginia Genevieve 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.1655112571.txt.gz · Last modified: 2022/06/13 09:29 by peter