Print a range of lines
Print only lines 10-20; -n turns off the default output
sed -n '10,20p' file.txt
- tool
- sed15 commands
More sed commands
-
sed -n '/ERROR/p' app.logPrint only lines that contain ERROR
-
sed '/^server_name/i # Added by deploy script' nginx.confInsert a comment line before each server_name directive
-
sed '/^\[defaults\]/a ansible_python_interpreter=/usr/bin/python3' ansible.cfgAdd a setting line after the [defaults] header
-
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