sed Flashcards

1
Q

sed

A

sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).

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

sed

  • e
  • f
  • E, -r
  • s
A
  • e script, –expression=script, Add the script to the commands to be executed.
  • f script-file, –file=script-file, Add the contents of script-file to the commands to be executed.
  • E, -r, –regexp-extended, Use extended regular expressions in the script.
  • s, –separate, Consider files as separate rather than as a single, continuous long stream.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

sed ‘ s/string1/string2/ ‘ file1.txt

A

This command substitutes and replaces the first occurance of string2 with string1.

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

sed ‘ s/string1/string2/2 ‘ file1.txt

A

This command substitutes and replaces the second occurance of string2 with string1.

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

sed ‘ s/string1/string2/g ‘ file1.txt

A

This command substitutes and replaces all occurences of string2 with string1. The /g stands for global.

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

sed ‘ s/string1/string2/3g ‘ file1.txt

A

This command replaces string2 with string1 from the third occurance and beyond. Any number can be added to that range.

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