For the things in life which make me glad I'm not dead yet.
Bash – Snip Leading Zeros
With the right regular expression, you can strip all the leading zeroes from your data fields with just a few characters:
valueWithoutZeroes="$(echo $valueWithZeroes | sed 's/0*//')"
Source: www.askdavetaylor.com
| Print article | This entry was posted by Dave on September 15, 2011 at 7:24 pm, and is filed under Snippets. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |