20100318

Removing leading zero using awk

Had to extract data from rrdtool and feed it to Zabbix. Problem was I kept getting leading zero variables. This removes any leading zero:

rrdtool fetch lighttpd.rrd AVERAGE -s -60s \
| grep -v nan \
| grep -v Requests \
| awk '{printf "%d",$2}' \
| awk '{print $1 + 0}'

to test it yourself:

echo 000000105 | awk '{ print $1 + 0}'

0 Comments:

Post a Comment

<< Home