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
To cut entire column from a file and apend it to another file as another column sakthifire Shell Programming and Scripting 4 06-25-2008 01:27 AM
How to check Null values in a file column by column if columns are Not NULLs Mandab Shell Programming and Scripting 7 03-15-2008 06:57 AM
Finding unique reocrds at a particular field dsravan Shell Programming and Scripting 7 12-11-2007 01:03 PM
cut the third column from a file isingh786 Shell Programming and Scripting 8 12-29-2005 08:11 AM
Replace 10th column with a new column--- Terriblly hurry ahmedwaseem2000 Shell Programming and Scripting 2 09-05-2005 10:10 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-05-2005
Registered User
 

Join Date: Oct 2005
Posts: 3
Lightbulb to add new column for all reocrds in a file in KSH please

i want to add a new column at the end for all the reocrds in a
file

for ex:

file name is abc.wlg.x.y.z
records like
1,2,3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8
2,3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,k
3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,k,l
4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,u,i,o
1,2,3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,i,u

i want to add xyz for all the records into file abc.wlg.x.y.z
and output like
1,2,3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,xyz
2,3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,k,xyz
3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,k,l,xyz
4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,u,8,u,i,o,xyz
1,2,3,4,5,6,8,y,u,8,1,2,3,4,5,6,8,y,i,u,xyz

Last edited by pulse2india; 11-05-2005 at 09:36 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 11-05-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Try this:
sed 's/$/,xyz/' < inputfile > outputfile
Reply With Quote
  #3  
Old 11-05-2005
Registered User
 

Join Date: Sep 2005
Location: Chennai
Posts: 80
If you want an in place substitution:

perl -p -i -e 's/$/,xyz/g' file_name

Just a substituted output:

sed 's/$/,xyz/g' file_name
Reply With Quote
  #4  
Old 11-06-2005
Registered User
 

Join Date: Oct 2005
Posts: 3
to add columns to all the records in a file

thanks for input...
i want to change like i have to add 'xyz' in 18th position and its a comma delimeted one.
Thanks in advance
Reply With Quote
  #5  
Old 11-06-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Code:
nawk ' 
  BEGIN {
     FS=OFS=","
  }
  { $17=$17 FS "xyz" }
  1' inputfile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:36 AM.


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

Content Relevant URLs by vBSEO 3.2.0