![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding columns to a file | figaro | UNIX for Dummies Questions & Answers | 5 | 07-20-2008 10:50 PM |
| comparing files - adding/subtracting/formating columns | oabdalla | Shell Programming and Scripting | 7 | 06-13-2008 12:20 AM |
| Adding columns to excel files using Perl | dolo21taf | Shell Programming and Scripting | 1 | 02-20-2008 03:13 AM |
| Adding columns of two files | chandra321 | Shell Programming and Scripting | 6 | 04-06-2007 06:36 AM |
| adding columns | Kelam_Magnus | Shell Programming and Scripting | 9 | 01-25-2002 06:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Perl: adding columns in CSV file with information in each
Hi Wise UNIX Crew,
I want to add 3 different columns to the file in which: 1. The first new column pulls in today's date and time 2. Second column one has a '0' 3. Third column has the word 'ANY' going down the column If my file content is as follows: "7","a","abc",123" "8","b","cde","456" "9","c","fgh","789" This is what I want the file content to be: "2008-04-03 10:33:08",0,ANY,"7","a","abc",123" "2008-04-03 10:33:08",0,ANY,"8","b","cde","456" "2008-04-03 10:33:08",0,ANY,"9","c","fgh","789" Big brownie points in advance......and a bigger thanks S |
| Forum Sponsor | ||
|
|
|
|||
|
HI,
Speaking of Perl, i am a virgin, below is the AWK solution. Hope can help you somewhat. Code:
d=`date '+ %y-%m-%d %H:%M:%S'`
nawk -v dd="$d" 'BEGIN{FS=","}
{
printf("\"%s\",0,\"ANY\",%s,%s,%s,%s\n",dd,$1,$2,$3,$4)
}' filename
|
|||
| Google The UNIX and Linux Forums |