Thanks "olded", this is a great start. Now I just need help to make the output sorted in the order I need (see my original message). Any hints to do this? Thanks again!
A common way to save the integrity of the non sort columns is to add a dummy column, and then sort on it after sorting the primary. Here I'm adding a new dummy column to your datafile - using cat -n - which then becomes the column 1. Your primary sort is column 2; sorting on column 2 retains your numeric order. I hope this explanation made sense:
cat -n datafile|sort -k 2,2 -k 1,1 |
while read f1 f2 f3
do
if [[ "$f2" != "$f2_buf" ]]
then
printf "\n%s %s " $f2 $f3
f2_buf=$f2
else
printf "%s " $f3
fi
done
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.