amigo wrote: Sun Nov 21, 2021 5:21 pmCode: Select all
M_int=${M_int#${M_int%%[^0+-]*}}
That's very nice indeed -something I hadn't really looked into enough. Just tried that under bash, zsh, dash and zsh, where it works.
Which dash are you using?
It doesn't work in Fatdog's dash-0.5.9.1:
Code: Select all
# dash
# M_int="000000000000001.23"; echo ${M_int#${M_int%%[^0+-]*}}
000000000000001.23
#
I also built the latest (v0.5.11.5) with the same result.
What works though (which I discovered recently) is this:
Code: Select all
# dash
# M_int="000000000000001.23"; echo ${M_int#${M_int%%[!0+-]*}}
1.23
#
Greetings!