![]() |
|
|
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 |
| comparing values | Aditya.Gurgaon | Shell Programming and Scripting | 1 | 03-08-2009 11:25 PM |
| 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 |
| replace a column values with the first value in column | sumeet | UNIX for Advanced & Expert Users | 3 | 02-06-2007 01:13 PM |
| comparing two float values | kavitha | Shell Programming and Scripting | 2 | 04-03-2004 02:32 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Comparing values in column 1
Hi to all, I have the following text within inputfile Code:
data1,value1,value2 data1,value3,value2 data1,value5,value6 data2,value1,value2 data2,value3,value4 data3,value1,value2 data3,value3,value4 data4,value1,value2 data4,value3,value4 data4,value5,value6 I would like to associate in the same line all values taking as common value $1. I mean, compare the values in column 1 for consecutive lines, and if $1 of line_n is equal to $1 of line_n+1 put the data as follow: Code:
data1,value1,value3,value5,value2,value4,value6 data2,value1,value3,value2,value4 data3,value1,value3,value2,value4 data4,value1,value3,value5,value2,value4,value6 I think this could be done using FNR and/or NR variables, but I donīt know how to use them for this task. I was trying the next line, but fails because some syntax error: awk '{arr[i]==$1++}; {if{arr[i]==arr[i+1]}} {print $0, getline; print $0}' inputfile and something like NR=FNR, but I donīt know how. Please any help will be very appreciated. Best regards |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|