I need a bash script that will take a file and add a second \n character for every \n character already in the file:
that is:
abcd\nbcda
becomes
abcd\n\nbcda
how do I start. OR, should I write it in another language and wrap it in bash?
sed 'G' file > newfile
or
perl -nae 'print "$_\n";' file > newfile
or
while read ln
do
echo $ln; echo;
done < file > newfile
A very very simple way to do it.
cat inputfile.txt | while read a
do
echo $a >> outputfile.txt
echo "" >> outputfile.txt
done
echo '\n' >>outputfile.txt
or does echo automatically put in a newline?
Feb 1, 2010 at 17:14
echo -n
if you don't want echo to automatically output a newline.
Feb 1, 2010 at 19:06