Hello, i am trying to pad a column
A1
A2
A10
B2
B8
B12
to look like
A01
A02
A10
B02
B08
B12
using awk
awk '{sprintf ("%c" $1 "%03d",int (0))}' file.txt
getting
awk: (FILENAME=file.txt FNR=1) fatal: not enough arguments to satisfy format string
nawk '$1=sprintf("%s%02d",substr($1,1,1),substr($1,2))' file.txt
nawk is not an option for me
joeyg
May 2, 2011, 12:02pm
4
$ echo A1 | awk '{printf ("%1c%02d",substr($1,1,1),substr($1,2,2))}'
A01
$ echo A12 | awk '{printf ("%1c%02d",substr($1,1,1),substr($1,2,2))}'
A12
Yes the awk method worked. Thank you very much.
I am getting more in depth with awk at my job, any good study guides to suggest. currently only finding targeted related scenarios in my searches.
joeyg
May 2, 2011, 1:02pm
7
See
I have a couple of these books on a shelf behind my desk, for handy reference.