![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Concatenating the two lines in a file | srivsn | Shell Programming and Scripting | 6 | 07-17-2008 09:03 PM |
| Converting Binary decimal coded values to Ascii Values | gaur.deepti | UNIX for Advanced & Expert Users | 3 | 04-02-2008 12:33 PM |
| Extract values from log file | wdympcf | Shell Programming and Scripting | 5 | 08-10-2007 03:52 AM |
| Change the Values in a file | rudoraj | Shell Programming and Scripting | 6 | 09-18-2006 11:58 AM |
| concatenating static string to records in data file | gillbates | Shell Programming and Scripting | 5 | 06-22-2006 06:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi All,
I have a ',' delimited file and i would like concatenate a new value at a specific column. Example :- xXXX,XYZ,20071005,ABC,DEF,123 xXXX,XYZ,20071005,ABC,DEF,123 xXXX,XYZ,20071005,ABC,DEF,123 The output that i want is xXXX,XYZ,20071005001,ABC,DEF,123 xXXX,XYZ,20071005002,ABC,DEF,123 xXXX,XYZ,20071005003,ABC,DEF,123 ........ xXXX,XYZ,20071005010,ABC,DEF,123 xXXX,XYZ,20071005011,ABC,DEF,123 and so .... on.... As you see the only difference is in the Column # 3 where i want to add 001, 002, 003 .... till the end of file [ in the above example there are 11 records so last updated value is 20071005011 ], however all other values should remain the same. Please let me know if you have any doubts about the query. and thanks for your time. ![]() Amit |
|
||||
|
Quote:
Thanks for your time. Amit |
|
||||
|
Quote:
2) n=sprintf("%03d",c++) # string formatting. precede the number by 0's and fix it at length 3. Then assign the value to n eg 001, 002, till 999 3)$3=$3n #append 001 , 002 etc to field 3, which is the field with date, eg 20071005 which platform are you in? i am using GNU awk. |
|
||||
|
Quote:
I am using this on Solaris Box and i tried your solution how ever the output is different and it is adding the 001 in the front side, not sure why. So the output is 00171005 for "20071005". Will this be case of different platform... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|