#!/bin/bash file=$1 paste <(join -1 1 -2 2 -o 1.1 2.1 "$file" \ <(cut -f1,2 "$file" | sort -k2nr | nl | sort -k2) ) \ <( cut -f1,3 "$file" | sort -k2nr | nl | sort -k2 | cut -f1)