_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
ohazot | | docs | | about |
sed
— usage
and tips
SUBSTITUTION
- replace old with new
s/old/new/
- replace all occurrences
s/old/new/g
- replace the second occurrence
s/l/p/2
examplereturns "helpo"echo hello | sed s/l/p/2
path variables
The typical separator is /, which can conflict with pathnames. An option is to use another character as a separtor, eg.: @ :
echo "/some/path" | sed "s/\/some\/path/\/other\/directory/" echo "/some/path" | sed "s@/some/path@/other/directory@"
SEE ALSO
OpenBSD manpages
files
<sed.oh>