Delete blank lines
Remove all empty or whitespace-only lines
sed '/^[[:space:]]*$/d' file.txt
- tool
- sed15 commands
More sed commands
-
sed -n '10,20p' file.txtPrint lines 10 through 20 only (suppress default output with -n)
-
sed -n '/ERROR/p' app.logPrint only lines that match ERROR
-
sed '/^server_name/i # Added by deploy script' nginx.confInsert a comment line before every server_name directive
-
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