Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

1 total

Remove leading zeros via parameter expansion

# cf. http://codesnippets.joyent.com/posts/show/1816
i=004555
printf "%s\n" "${i}"
printf "%s\n" "${i#"${i%%[!0]*}"}"

i="${i#"${i%%[!0]*}"}"
printf "%s\n" "${i}"
1 total