How can I double the newlines in an output stream
sed G
is a well known one-liner for that.
Performance-wise, the most effective with the standard Unix tool chest would probably be:
paste -d '\n' - /dev/null
If you don't want to add an empty line after the last line:
sed '$!G'
To add the empty lines before the input lines:
paste -d '\n' /dev/null -
Or:
sed 'i\
/'
using pr
: Paginating Files
pr -t -d file.txt
output:
a b c d e
using awk
:
awk '{printf("%s\n\n",$0)}' file.txt
With awk
you can define the Output Record Separator as double new line:
awk -v ORS="\n\n" 1 file
Then, 1
performs the default awk
action: {print $0}
, that is, print the current line.