I want to insert 5 blank lines after every line in my input file.
foo.txt:
line 1
line 2
line 3
out.txt:
line 1
line 2
line 3
...
Solaris 5.10, nawk or sed.
I want to insert 5 blank lines after every line in my input file.
foo.txt:
line 1
line 2
line 3
out.txt:
line 1
line 2
line 3
...
Solaris 5.10, nawk or sed.
That's the job for sed:
sed -e 'G;G;G;G;G' file
With awk:
nawk -vORS='\n\n\n\n\n\n' 1 file
Or shorter version:
awk 'ORS="\n\n\n\n\n\n"' file
or avoid setting ORS for each input line:
awk 'BEGIN{ORS="\n\n\n\n\n\n"};1' file
Another one , with printf
cat file.txt | xargs printf "%s\n\n\n\n\n"
To output that to a file
(cat file.txt | xargs printf "%s\n\n\n\n\n") > out.txt
You might want to use nl for this, too. It comes to my mind because when I do stuff like that I often find it useful to retain the original line-numbers.
eval "nl -ba -s'$(printf "\n\n\n\n\n'")" <infile
Also pr is spec'd for the -doublespace argument - which will double all newlines in input on output.
But sed's good, too.