AWK Variables Flashcards

1
Q

provide an example using awk to search a file for the symbol #

A

cat [FILE] | awk /#/
Check’s [FILE] for any lines using the ‘#’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If the field separator is not a space or a tab than how would you define it for “:” ?

A

awk -F’,’ ‘{print NF}’ /home/file.csv

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

AWK Variables:
$0

A

used to call/print the
full output (line)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

AWK Variables:
$1, $2, $3 … $NF

A

used to call/print the
First, second, third, and last field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

AWK Variables:
NF

A

Number of Fields

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

AWK Variables:
NR

A

Number of Records (rows)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

AWK Variables:
OFS

A

Output Field Separator (default: [::Space::] )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

AWK Variables:
FS

A

Field Separator for input (default: [::Space::] )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

AWK Variables:
ORS

A

Output Record Separator (default: “\n”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

AWK Variables:
RS

A

Record Separator for input (default: “\n”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

AWK Variables:
FILENAME

A

The name of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly