Insert line before match sed
Insert a comment line before every server_name directive
sed '/^server_name/i # Added by deploy script' nginx.conf
more sed
all 15 commands →
Append line after match
sed '/^\[defaults\]/a ansible_python_interpreter=/usr/bin/python3' ansible.cfg
Case-insensitive substitution
sed 's/error/ERROR/gI' file.txt
Multiple expressions
sed -e 's/foo/bar/g' -e 's/baz/qux/g' file.txt
Strip leading/trailing whitespace
sed 's/^[[:space:]]*//;s/[[:space:]]*$//' file.txt
Address range substitution
sed '5,15s/DEBUG/INFO/g' app.log