![]() |
|
|
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 |
| how to read the column and print the values under that column | gemini106 | Shell Programming and Scripting | 6 | 03-28-2008 07:05 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 09:57 AM |
| Need help with switching field/column values | sonyd8 | Shell Programming and Scripting | 7 | 02-13-2008 01:10 AM |
| replace a column values with the first value in column | sumeet | UNIX for Advanced & Expert Users | 3 | 02-06-2007 01:13 PM |
| Replace 10th column with a new column--- Terriblly hurry | ahmedwaseem2000 | Shell Programming and Scripting | 2 | 09-06-2005 02:10 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
replace the column values.
I have the below file ...where some of the column values should replaced with desired values ....below file u can find that 3 column where ever 'AAA' comes should replaced with ' CC '
NOTE : we have to pass the column number ,AAA,CC (modified value) as the parameters to the code. File 1 : E100,A456,AAA,E12 E101,A22,BBB,E13 E101,A,AAA,E14 Result file : E100,A456,CC,E12 E101,A22,BBB,E13 E101,A,CC,E14 Please help ..... |
|
||||
|
Hey, if the figures is constant you can use this
![]() $ cat a E100,A456,AAA,E12 E101,A22,BBB,E13 E101,A,AAA,E14 $ awk -F, '{ if($3 ~ "AAA") {print $1","$2",""CC"","$4} else {print $0} }' a E100,A456,CC,E12 E101,A22,BBB,E13 E101,A,CC,E14 $ |
|
||||
|
replacing multiple columns ???
If iam having multiple columns to be replaced ....does the above code works ... please provide the code for the below.....
Below i have to replace 3 rd and 5 th column to 'CC' & 'XXX' repectively ..... File1 : E100,A456,AAA,E12,MMM E101,A22,BBB,E13,MMM E101,A,AAA,E14 ,MMM Result : E100,A456,CC,E12,XXX E101,A22,BBB,E13,XXX E101,A,CC,E14 ,XXX |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|