Skip to content
cheatsheet
home
/
cv
/
weblog
/
cheatsheet
/
proxy
/
vpn
/
status
/
links
EN
RU
☾
New version available
reload
×
cheatsheet
/
sed
/
Address range substitution
Address range substitution
sed
Apply substitution only to lines 5 through 15
sed '5,15s/DEBUG/INFO/g' app.log
⎘ copy
#sed
#linux
more sed
all 15 commands →
Extract value from key=value file
sed -n 's/^DB_HOST=//p' .env
Substitute first match per line
sed 's/foo/bar/' file.txt
Substitute all matches (global)
sed 's/foo/bar/g' file.txt
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