awk printf dillemma

Please help me format this file:

Source file looks like this, there are three columns, separated by space. First column has varrying width:

1 248105240 W25_2013
10 248103710 W06_2013
100 248103710 W06_2013
1000 248103710 W06_2013

I need to transform the file into a fixed width per column. Column 1 should have 20 characters, column 2 should have 20 characters as well while column 3 should have 8 characters. Output should be like this:

1                   248105240           W25_2013
10                  248103710           W06_2013
100                 248103710           W06_2013
1000                248103710           W06_2013

Change the value in red to fit your needs

awk '{ printf "%-20s %-20s %s\n", $1, $2, $3 }' l
1                    248105240            W25_2013
10                   248103710            W06_2013
100                  248103710            W06_2013
1000                 248103710            W06_2013
2 Likes