![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding spaces to record | nvenkat010 | Shell Programming and Scripting | 3 | 01-28-2008 10:24 AM |
| splitting a record and adding a record to a file | rsolap | Shell Programming and Scripting | 1 | 08-13-2007 10:58 AM |
| Select Record based on First Column | mgirinath | Shell Programming and Scripting | 8 | 07-15-2007 10:38 PM |
| FILE:Adding new column | sandeep_hi | Shell Programming and Scripting | 2 | 06-09-2006 06:46 AM |
| Adding a column of numbers | Khoomfire | UNIX for Advanced & Expert Users | 1 | 01-18-2006 01:55 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
adding a column at the end of the record
hello.,
i have a .txt file. inside the .txt file i have., /home/ss/cca.costco.transaction_date /home/sk/cca.costco.transaction_date /home/st/cca.costco.transaction_date /home/sv/cca.costco.transaction_date cca.costco.transaction_date is the file name. inside the file there are some 100 records. there are 28 columns. each field is comma delimited. i have to add a 29th column in each record in each file. once it adds a number in all the records in that file next it has to go to the next file and add the number in 29th columns in the next file. it has to do it for all the files in that .txt file. say i have to add a number 123 in the 1st file, 135 in 2nd file so on this is my business requirement. can anyone help me in doing this thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
here's something to start with...
Code:
#!/bin/ksh
for fileName in $(< TXTfile.txt)
do
sum=$(nawk -F, '{sum+=$29}END {print sum}' ${fileName})
echo "file->[$fileName}] sum->[${sum}]"
done
Last edited by vgersh99; 11-07-2005 at 08:32 AM. Reason: changed the "while" to "for" loop |
|
#3
|
||||
|
||||
|
Quote:
What is the "value" of your new 29-th field? |
||||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|