![]() |
|
|
|
|
|||||||
| 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 |
| replace the column values. | charandevu | Shell Programming and Scripting | 6 | 04-01-2008 11:21 PM |
| 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 |
| Need help with switching field/column values | sonyd8 | Shell Programming and Scripting | 7 | 02-12-2008 10:10 PM |
| replace a column values with the first value in column | sumeet | UNIX for Advanced & Expert Users | 3 | 02-06-2007 10:13 AM |
| Capturing the values of column in one parameter | mgirinath | Shell Programming and Scripting | 5 | 06-14-2006 10:43 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi all
how to read the column and print the values under that column ...?? file1 have something like this cat file1 ======= column1, column2,date,column3,column4..... 1, 23 , 12/02/2008,...... 2, 45, 14/05/2008,..... 3, 56, 16/03/2008,..... cat file2 ======= column1,date,column3,column4..... 1,12/02/2008, 34,...... 2,14/05/2008,56, ..... 3,16/03/2008,78...... i need output like this cat file1 ===== date 12/02/2008 14/05/2008 16/03/2008 cat file2 ===== date 12/02/2008 14/05/2008 16/03/2008 only date filed column values ... pls help ... thx in advance.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
awk -F"," '{print $3}'file1
Similarly for file2...
awk -F"," '{print $2}'file2
The o/p will appear on the screen....redirect to a file as per ur requirment |
|
#3
|
|||
|
|||
|
thx for respond,
this i knew , but i need a script to handle that column date date column maybe $1 , $2 ,$3, $4..... thx, |
|
#4
|
|||
|
|||
|
Hope this helps
Code:
awk -F"," '/date/{}{print $(NF-1)}' testfile
|
|
#5
|
|||
|
|||
|
Actually you are on the right track there.
Code:
awk -F, 'NR==1{for (i=0; i<=NF; i++) { if ($i == "date") break; } }
{ print $i }'
|
|
#6
|
|||
|
|||
|
Meanwhile i was trying...heres one approach...
but i guess ...not a gd one Code:
awk -F"|" '{
split ($0,a,",")
for (i=0 ;i<=NF;i++)
{
if (a[i] == "date")
val =i
}
} { print $val}'
|
|
#7
|
|||
|
|||
|
Thanks 2 all
|
|||
| Google The UNIX and Linux Forums |