Home » Questions » Computers [ Ask a new question ]

Write a bashscript to double every newline character in a text file?

Write a bashscript to double every newline character in a text file?

I need a bash script that will take a file and add a second \n character for every \n character already in the file:

Asked by: Guest | Views: 55
Total answers/comments: 2
Guest [Entry]

"sed 'G' file > newfile

or

perl -nae 'print ""$_\n"";' file > newfile

or

while read ln
do
echo $ln; echo;
done < file > newfile"
Guest [Entry]

"sed can do this quite easily

sed 'G' file"