The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to remove duplicate records with out sort svenkatareddy Shell Programming and Scripting 19 06-11-2008 11:10 AM
How to remove duplicate records with out sort svenkatareddy SUN Solaris 2 02-28-2008 04:38 AM
Duplicate records from oracle to text file. shilendrajadon UNIX for Advanced & Expert Users 1 01-10-2008 07:21 AM
Remove all instances of duplicate records from the file vukkusila Shell Programming and Scripting 3 12-12-2007 03:50 AM
How to extract duplicate records with associated header record run_eim UNIX for Dummies Questions & Answers 17 01-16-2007 07:46 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-21-2007
Registered User
 

Join Date: Feb 2007
Location: Milwaukee
Posts: 24
Records Duplicate

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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-21-2007
Registered User
 

Join Date: Feb 2006
Posts: 65
Smile

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

--------------------------------------------------------------
Reply With Quote
  #3 (permalink)  
Old 02-21-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
awk ' 1 ; 1 ; 1' file
Reply With Quote
  #4 (permalink)  
Old 02-21-2007
Registered User
 

Join Date: Dec 2005
Location: Boston, USA
Posts: 65
this could be one of the option..

{ rm -f infile && awk '{ for (i=0;i<3; i++) { print $0 } }' > infile; } < infile

--Manish Jha
Reply With Quote
  #5 (permalink)  
Old 02-21-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
sed "s/.*/&\\
&\\
&/" file
Reply With Quote
  #6 (permalink)  
Old 02-21-2007
Registered User
 

Join Date: Feb 2007
Location: Milwaukee
Posts: 24
Thank you to all gurus for your time.
Reply With Quote
  #7 (permalink)  
Old 02-21-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,454
one more,

Code:
perl -e 'while (<>) { print $_, $_, $_ }' file
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0