Occasionally when working in a Linux/Unix environment comes the need to left pad numbers with zeros (add leading zeros to numbers). This is often done to make a series of numbers the same length. An example of doing this with awk can be seen below:

# left pad with zeros using awk
echo 99 | awk '{printf "%05d\n", $0}'
> 00099

Leave a Reply

How to Left Pad Numbers in AWK