Skip to content
cheatsheet
home
/
cv
/
weblog
/
cheatsheet
/
proxy
/
vpn
/
status
/
links
EN
RU
☾
New version available
reload
×
cheatsheet
/
sed
/
Substitute all matches (global)
Substitute all matches (global)
sed
Replace every occurrence per line with the /g flag
sed 's/foo/bar/g' file.txt
⎘ copy
#sed
#linux
more sed
all 15 commands →
In-place edit
sed -i 's/old/new/g' config.cfg
In-place edit with backup
sed -i.bak 's/old/new/g' file.txt
Delete matching lines
sed '/^#/d' config.txt
Delete blank lines
sed '/^[[:space:]]*$/d' file.txt
Print specific line numbers
sed -n '10,20p' file.txt