@ Panyam and @ Rakesh thanks a lot.... It did serve my purpose.... Thanks.. But i am stil working on it.. and will get back, as my original input file is different, so trying to impliment on it... I think it wil be better to have a delimiter to differentiate...
@ ghostdog74 ya da its a type error sorry for confusion
---------- Post updated 06-26-09 at 10:10 AM ---------- Previous update was 06-25-09 at 05:59 PM ----------
Originally quoted by Rakesh:
----------------------------------------
/bin/sort inputfile | awk ' BEGIN { FS=OFS=" ";getline;prev=$1" "$2" "$3;s=$4 }
{
curr=$1" "$2" "$3
# print curr
if ( prev == curr )
s=s" "$4
if ( prev != curr )
{
print prev " " s
prev=curr;s=$4
}
}
END {
print prev " " s
}'
------------------------------------------
This piece of code worked fine but thr is one more thing i would like to highlight.. You have sirted entire inputfile hence the occurances are not printed in order they are see the example:
inputfile:
a b c 1
a b c 2
a b c 3
x y z 6
x y z 44
a b c 89
x y z 9
b s c 100
a b c 19
Output of above code:
a b c 1 19 2 3 89
b s c 100
x y z 44 6 9
So here al these values appended ones also sorted..
Instead shud get as below:
a b c 1 2 3 89 19
b s c 100
x y z 6 44 9
I dont mind the order of values if 1,2,3.. N then can sort only til N-1.. Bec last value is one with different values
Please help in this regard.