Dup Ver Goto 📝

BashVariableSubstitution

PT2/aw/os/shell does not exist
To
20 lines, 60 words, 419 chars Page 'BashVariableSubstitution' does not exist.

Remove leading 0's

This uses extended globbing. More of that [http://mywiki.wooledge.org/glob#extglob here]. Also see BashExtendedGlobs. To enable this:

shopt -s extglob

and then

A="00123"
B=${A##+(0)}    # B := 123

Here the ## means remove longest match, and +(0) means match 1 or more 0's.

Related example:

A="abababacde"
B="${A##+(ab)}"     # B := acde