Append a line after a match
Add a setting line after the [defaults] header
sed '/^\[defaults\]/a ansible_python_interpreter=/usr/bin/python3' ansible.cfg
- tool
- sed15 commands
More sed commands
-
sed 's/error/ERROR/gI' file.txtThe /I flag in GNU sed makes the match case-insensitive
-
sed -e 's/foo/bar/g' -e 's/baz/qux/g' file.txtApply several replacements in one command
-
sed 's/^[[:space:]]*//;s/[[:space:]]*$//' file.txtRemove spaces at the start and end of each line
-
sed '5,15s/DEBUG/INFO/g' app.logApply the replacement only to lines 5-15
-
sed -n 's/^DB_HOST=//p' .envPrint the DB_HOST value from a .env file