perl.
Suposição: a cidade tem apenas uma palavra.
perl -MList::Util=max -lane '
push @num, shift @F;
push @city, pop @F;
push @name, join(" ", @F);
END {
@max = (
max(map {length} @num),
max(map {length} @name),
max(map {length} @city)
);
printf "%-*s %-*s %-*s\n",
$max[0], $num[$_],
$max[1], $name[$_],
$max[2], $city[$_]
for (0..$#num);
}
' <<END
Index Name City
1. Ravi Bhuva Ahmedabad
2. Gaurav Bhuva Rajkot
3. Nimesh Godhasara Junagadh
4. Abhyuday Godhasara Nadiyad
42. a b c d e f city
100. abcd xyz
END
saída
Index Name City
1. Ravi Bhuva Ahmedabad
2. Gaurav Bhuva Rajkot
3. Nimesh Godhasara Junagadh
4. Abhyuday Godhasara Nadiyad
42. a b c d e f city
100. abcd xyz