Balasubramaniam Natarajan <bala150...@gmail.com> writes: > Okay found out what to do, however not sure if there are some more > efficient method. > > while read line > do > domain=`echo $line | cut -d" " -f1` > echo $domain >> FirstColumn.txt > done < input.txt > > cat FirstColumn.txt | sort -u > unique.txt > mv unique.txt FirstColumn.txt > > while read line > do > grep $line input.txt | cut -d" " -f3 | sed ':a;N;$!ba;s/\n/ | /g' > done < FirstColumn.txt >
Doesn't sort has key option? Will this give the desired result? sort -k 1 input.txt Regards, Noorul > On Thu, Oct 9, 2014 at 8:49 AM, Balasubramaniam Natarajan < > bala150...@gmail.com> wrote: > >> Oops sorry the input file looks like this. >> >> Bala -> 54; >> Bala -> 57 >> Bala -> 56; >> Bala -> 60 >> Name -> 64 >> Name -> 67 >> Name -> 67 >> Name -> 70 >> Super -> 78 >> First -> 60 >> First -> 29 >> >> On Thu, Oct 9, 2014 at 8:44 AM, Balasubramaniam Natarajan < >> bala150...@gmail.com> wrote: >> >>> Hi >>> >>> I have a question of how to print the longest line in bash scripting ? >>> Most appropriate would be to search for longest dictionary value. >>> >>> *Input file contains* >>> Bala -> 54; 56; 57 >>> Bala -> 54; 57 >>> Bala -> 56; 57 >>> Bala -> 54; 56; 57;60 >>> Name -> 64; 66; 67 >>> Name -> 64; 67 >>> Name -> 66; 67 >>> Name -> 64; 66; 67;60 >>> Super -> 78 >>> First -> 29, 60 >>> First -> 29 >>> >>> *Output should be* >>> Bala -> 54; 56; 57;60 >>> Name -> 64; 66; 67;60 >>> Super -> 78 >>> First -> 29, 60 >>> >>> -- >>> Regards, >>> Balasubramaniam Natarajan >>> http://blog.etutorshop.com >>> >> >> >> >> -- >> Regards, >> Balasubramaniam Natarajan >> http://blog.etutorshop.com >> _______________________________________________ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc ILUGC Mailing List Guidelines: http://ilugc.in/mailinglist-guidelines