Text Manipulation Flashcards

1
Q

How do you display the first 5 lines of a file?

A

head -n 5 file.extension

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

How do you display the last 3 lines of a file?

A

tail -n 3 file.extension

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

How do you display the output of a file starting from line 2?

A

tail -n +2 file.extension

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

How do you sort a file by alphabetical order?

A

sort file.extension

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

How do you sort a file by alphabetical order but in reverse order?

A

sort -r file.extension

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

How do you display the first 3 letters of ever line in a file?

A

cut -c 1-3 file.extension

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

What does grep “ap[pe]” file.extension do?

A

Returns any lines that contain the characters “app” or “ape”

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

What does grep “.ap” file.extension do?

A

Returns any lines that contain the characters any character, followed by “ap”

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

What does grep “ap*l” file.extension do?

A

Returns any lines that contain characters “a”, followed by p, followed by p (0 or more) and l

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

What does grep -E “el?o” file.extension do?

A

Returns any lines that contain characters that starts with an “e”, followed by “l”, followed by an “l” (optional), and ends in a “o”

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

How do you get the word count of a document?

A

wc -l file.extension

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