Example 1
Slicing the input
bash$ ls -lg | awk '{ print $3, ":", $7 }'
- Who tells awk which character to take as field separator?
- And why are there spaces between the fields in the output string?
Specifying the field separator
BEGIN { FS=":"; OFS=""; }
{ print $1, "'s name is: ", $5 }
called as
awk -f programfile /etc/passwd
Some Builtin-Variables
- FS field separator
- OFS output field separator
- NF number of fields
- RS row separator (default: "\n")
- ORS output row separator (default: "\n")
- ARGC number of command line arguments
- ARGV verctor of command line arguments
- etc.