AWK Formatting Output Flashcards

1
Q

Common escape sequences for echo -e or printf:
\b

A

Backspace

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

Common escape sequences for echo -e or printf:
\f

A

Form feed

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

Common escape sequences for echo -e or printf:
\n

A

Newline (line feed)

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

Common escape sequences for echo -e or printf:
\r

A

carriage return

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

Common escape sequences for echo -e or printf:
\t

A

horizontal tab

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

Common escape sequences for echo -e or printf:
\v

A

vertical tab

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

awk ‘BEGIN{printf “|%10s|\n”, “hello”}’

A

Right align
| hello|

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

awk ‘BEGIN{printf “|%-10s|\n”, “hello”}’

A

Left align
|hello |

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

Common AWK specifiers:
c

A

ASCII Character

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

Common AWK specifiers:
d

A

Decimal integer

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

Common AWK specifiers:
e, E, F

A

FLoating-point format

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

Common AWK specifiers:
o

A

Unsigned octal value

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

Common AWK specifiers:
s

A

String

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

Common AWK specifiers:
%

A

Literal %

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

Break down how this ss output is parsed with AWK:
ss -lunt | awk ‘NR>1{i=split($5,a,”:”);print a[i]}’

A

ss -lunt
Lists TCP ports that are listening
and Lists UDP ports that are open

NR>1
skip the first line

i=split($5,a,”:”)
split our input in field 5 (delimiter is colon)

print a[i]
print the last field from each split operation

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