ed
🡸 lup:tips:
- matching the most unique part requires the least typing.
,n
.- use
g/PAT/ s/PAT/NEW/
to report the first substitions on all lines. s/PAT/NEW/gp
prints line after substitution.s/PAT/NEW/gn
prints with line-number.
- use
g/PAT/t. \↲s/PAT/NEW
to copy and modify line. - add line spacing by escaping newlines:
s/$/\↲↲
- doublespace the whole document:
,s/$/\↲↲
- doublespace the whole document:
- alternate delimiters help with search space with
/
.- e.g.:
s@/bin@/usr/bin@g
@
is most people’s first go-to, but i prefer,
- e.g.:
bonus: sed
tips:
- delete lines that contain PAT, but not if it contains SKIP
sed '/PAT/{/SKIP/!d}'