sed Flashcards

1
Q

The sed Command definition:

A

This command displays the contents of a file or stream. (Just like cat).

** The original file does not get affected by sed. **

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

The sed Command syntax:

A

sed options ‘address action’ file(s)

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

sed -n

A

This suppresses the display of all lines when the p (print) action is used

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

p

A

prints lines on standard output

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

d

A

delete lines

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

s (sed)

A
  • sed action
  • substitution (special format)

s/searchText/replacementText/ replaces first occurrence on lines

s/searchText/replacementText/g replaces all occurrences on lines

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

^ (sed)

A

The beginning of a line

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

q

A

quits after reading up to addressed line

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

r filename

A

places contents of file filename after line

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

w filename

A

writes addressed lines to file filename

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

=

A

prints line number addressed

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

s/s1/s2/

A

Replaces first occurrence of expression s1 in all lines with expression s2

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

s/s1/s2/g

A

As above but replaces all occurrences

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