sed Flashcards
The sed Command definition:
This command displays the contents of a file or stream. (Just like cat).
** The original file does not get affected by sed. **
The sed Command syntax:
sed options ‘address action’ file(s)
sed -n
This suppresses the display of all lines when the p (print) action is used
p
prints lines on standard output
d
delete lines
s (sed)
- sed action
- substitution (special format)
s/searchText/replacementText/ replaces first occurrence on lines
s/searchText/replacementText/g replaces all occurrences on lines
^ (sed)
The beginning of a line
q
quits after reading up to addressed line
r filename
places contents of file filename after line
w filename
writes addressed lines to file filename
=
prints line number addressed
s/s1/s2/
Replaces first occurrence of expression s1 in all lines with expression s2
s/s1/s2/g
As above but replaces all occurrences