AWK Variables Flashcards
provide an example using awk to search a file for the symbol #
cat [FILE] | awk /#/
Check’s [FILE] for any lines using the ‘#’
If the field separator is not a space or a tab than how would you define it for “:” ?
awk -F’,’ ‘{print NF}’ /home/file.csv
AWK Variables:
$0
used to call/print the
full output (line)
AWK Variables:
$1, $2, $3 … $NF
used to call/print the
First, second, third, and last field
AWK Variables:
NF
Number of Fields
AWK Variables:
NR
Number of Records (rows)
AWK Variables:
OFS
Output Field Separator (default: [::Space::] )
AWK Variables:
FS
Field Separator for input (default: [::Space::] )
AWK Variables:
ORS
Output Record Separator (default: “\n”)
AWK Variables:
RS
Record Separator for input (default: “\n”)
AWK Variables:
FILENAME
The name of the file