Insert line before match
Insert a comment line before every server_name directive
sed '/^server_name/i # Added by deploy script' nginx.conf
- tool
- sed15 commands
More sed commands
-
sed '/^\[defaults\]/a ansible_python_interpreter=/usr/bin/python3' ansible.cfgAppend a setting line after the [defaults] header
-
sed 's/error/ERROR/gI' file.txtGNU sed /I flag for case-insensitive match
-
sed -e 's/foo/bar/g' -e 's/baz/qux/g' file.txtApply multiple substitutions in one command
-
sed 's/^[[:space:]]*//;s/[[:space:]]*$//' file.txtTrim leading and trailing whitespace from each line
-
sed '5,15s/DEBUG/INFO/g' app.logApply substitution only to lines 5 through 15