Hi Everyone,
I have a flat file of 1000 unique records like following : For eg
Andy,Flower,201-987-0000,12/23/01
Andrew,Smith,101-387-3400,11/12/01
Ani,Ross,401-757-8640,10/4/01
Rich,Finny,245-308-0000,2/27/06
Craig,Ford,842-094-8740,1/3/04
.
.
.
.
.
.
Now I want to duplicate each row 3 times. How shall I do ?
Please advice
Ganesh,
I'm sure that would be better solution that what I have below:
---------------------------------------------------------
while true
do
read record
if [ "$record" = "" ]
then
break
fi
echo $record >> ./outputfile
echo $record >> ./outputfile
echo $record >> ./outputfile
done < ./inputfile
### if the file name has to be changed :
rm ./inputfile
mv outputfile inputfile
--------------------------------------------------------------
this could be one of the option..
{ rm -f infile && awk '{ for (i=0;i<3; i++) { print $0 } }' > infile; } < infile
--Manish Jha
anbu23
February 21, 2007, 2:40pm
5
sed "s/.*/&\\
&\\
&/" file
Thank you to all gurus for your time.
one more,
perl -e 'while (<>) { print $_, $_, $_ }' file
aigles
February 22, 2007, 5:44am
8
Another sed solution :
sed -n '/./{p;p;p;}' file
Jean-Pierre.
aigles
February 22, 2007, 7:47am
10
anbu23:
sed '/./{p;p;}' file
My sed command was based on hemangjani solution which doesn't output empty lines.
That wasn't an requirement, i read initial post without attention.
A solution even simpler :
sed 'p;p' file
Jean-Pierre.