cat FILENAME | perl -e 'foreach $Line (<STDIN>) { @Cols=($Line=~/^s*(d+)s*(.*?)s*$/); push(@{$Link{$Cols[0]}}, $Cols[1]); } foreach $List (values %Link) { print join(" ", @{$List})." "; }'