ubuntu:file:delete_empty_lines
This is an old revision of the document!
Table of Contents
Ubuntu - File - Delete empty lines
Delete empty lines using sed.
sed '/^$/d' <input-file> echo "LINE" | sed '/^$/d' echo "$VAR" | sed '/^$/d' sed '/^[[:space:]]*$/d' input_file
Examples
Delete all empty lines from a file
sed '/^$/d' /tmp/data.txt
Store output to another file use redirection operator
sed '/^$/d' /tmp/data.txt > /tmp/output.txt
Update the file directly
sed -i '/^$/d' /tmp/data.txt
ubuntu/file/delete_empty_lines.1576443992.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)