9.1. Calling awk
There are three ways awk can be invoked. You can either specify awk on the command line like this:
awk [-F field-separator] 'commands' input-file(s)
where ‘commands’ are the actual awk commands. This method is the one that we will use most in this chapter.
In the above example the use of the -F field separator is optional, as awk uses the <space> as a default field separator. So if you are scanning text which has spaces between fields you don’t have to specify this option; however if you’re scanning the passwd file, for example, then those fields are separated by a colon, so you’ll have to state this with the -F option, like this:
awk -F: 'commands' input-file
The second method is to insert all the awk commands in a file then ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access