| Author |
Message |
   
Gamingfan
Junior Artist Username: Gamingfan
Post Number: 169 Registered: 08-2012 Posted From: 59.93.115.195
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 05:21 am: |
    |
Jupiter:30 years in the industry lo sagam ... rase code lo clarity miss avadu ... vache bug lo complexity miss avadhu ... rao .. code'swara rao ...
hats off oka kotta vishayam telusukunna by the above code I AM NOT LAZY I JUST REST BEFORE I GET TIRED! LOVE IS THE SLOWEST FORM OF SUICIDE! |
   
Platypus
Comedian Username: Platypus
Post Number: 1062 Registered: 01-2008 Posted From: 122.169.172.142
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 05:19 am: |
    |
Platypus:Your solution is much better. Thank you. I will go with yours.
With the assumption that there will be only two rows per key. My solution works with any number of rows per key i guess. But for the requirement, I am sure there will be only two rows per key. So I will go with the simpler solution  Naaku nacchindi janaalaki nacchadu... Janaalaki nacchindi naaku nacchadu... Nenanthe.. adho type. |
   
Jupiter
Moderator Username: Jupiter
Post Number: 11595 Registered: 05-2011
Rating:  Votes: 5 (Vote!) | | Posted on Friday, August 10, 2012 - 05:18 am: |
    |
Platypus:Your solution is much better. Thank you. I will go with yours.
30 years in the industry lo sagam ... rase code lo clarity miss avadu ... vache bug lo complexity miss avadhu ... rao .. code'swara rao ... Wrong is wrong even if every one is doing it .. Right is always right even if no one is doing it!!! |
   
Platypus
Comedian Username: Platypus
Post Number: 1061 Registered: 01-2008 Posted From: 122.169.172.142
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 05:16 am: |
    |
Jupiter:# awk -F '|' '{key = $1; one = $2; getline; two = $2; print key "|" one "|" two
' sample.txt } Your solution is much better. Thank you. I will go with yours. Naaku nacchindi janaalaki nacchadu... Janaalaki nacchindi naaku nacchadu... Nenanthe.. adho type. |
   
Platypus
Comedian Username: Platypus
Post Number: 1060 Registered: 01-2008 Posted From: 122.169.172.142
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 05:13 am: |
    |
Got it. awk 'BEGIN{FS="|"} {a[$1];b[$1]=b[$1]"|"$2}END{for (i in a) printf("%s%s\n", i,b[i])}' $file does the trick. Thanks anyway  Naaku nacchindi janaalaki nacchadu... Janaalaki nacchindi naaku nacchadu... Nenanthe.. adho type. |
   
Jupiter
Moderator Username: Jupiter
Post Number: 11594 Registered: 05-2011
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 05:13 am: |
    |
# awk -F '|' '{key = $1; one = $2; getline; two = $2; print key "|" one "|" two}' sample.txt 1|2.56|3.45 2|2.78|3.55 3|2.98|2.76 Wrong is wrong even if every one is doing it .. Right is always right even if no one is doing it!!! |
   
Gamingfan
Junior Artist Username: Gamingfan
Post Number: 167 Registered: 08-2012 Posted From: 59.93.115.195
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 05:01 am: |
    |
grep and sed taruvatadega awk ante? also there are other versions like nawk and gawk do u want to sculpt the commands? I AM NOT LAZY I JUST REST BEFORE I GET TIRED! LOVE IS THE SLOWEST FORM OF SUICIDE! |
   
Jupiter
Moderator Username: Jupiter
Post Number: 11593 Registered: 05-2011
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 04:57 am: |
    |
let me give a try Wrong is wrong even if every one is doing it .. Right is always right even if no one is doing it!!! |
   
Platypus
Comedian Username: Platypus
Post Number: 1059 Registered: 01-2008 Posted From: 122.169.172.142
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, August 10, 2012 - 04:53 am: |
    |
Help please. I have a file that has the following contents 1|2.56 1|3.45 2|2.78 2|3.55 3|2.98 3|2.76 I need to get the following output 1|2.56|3.45 2|2.78|3.55 3|2.98|2.76 How to do it in AWK? I can write a 10 line script to do it but was wondering if there is a single AWK command that does it. Naaku nacchindi janaalaki nacchadu... Janaalaki nacchindi naaku nacchadu... Nenanthe.. adho type. |