Linux sort and cut multiple columns

cutsort

I have the following file named "info":

White:73:Mars:1543:Manuel
Green:17:Jupiter:1968:Sebastian
Blue:24:Venus:1970:Anna
Red:35:Neptune:1122:Javier
Yellow:135:Earth:1234:Raymond

I need to use cut and sort, to show only the columns with planest and names, sorted. This means I have to be left with:

Earth:Anna
Jupiter:Javier
Mars:Manuel
Neptune:Raymond
Venus:Sebastian

I tried using
cut -d: -f3,5 info | sort -t: -k1,1 -k2,2
but it only sorted the first column and not the second.

I also tried
cut -d: -f3,5 info | sort -t: -k1,1 -k2,2 | sort -t: -k2,2
but this only sorted the second column.

Any and all help is appreciated

Best Answer

Sorting columns Individually:

paste -d: <(cut -d: -f3 info | sort) <(cut -d: -f5 info | sort)
Earth:Anna
Jupiter:Javier
Mars:Manuel
Neptune:Raymond
Venus:Sebastian
Related Question