Given a shell variable whose value is a semantic version, how can I create another shell variable whose value is (tuple 1 × 1000000) + (tuple 2 × 1000) + (tuple 3) ?
E.g.
$ FOO=1.2.3
$ BAR=#shell magic that, given ${FOO} returns `1002003`
# Shell-native string-manipulation? sed? ...?
I'm unclear about how POSIX-compliance vs. shell-specific syntax comes into play here, but I think a solution not bash-specific is preferred.
Update: To clarify: this isn't as straightforward as replacing ".
" with zero(es), which was my initial thought.
E.g. The desired output for 1.12.30
is 1012030
, not 100120030
, which is what a .
-replacement approach might provide.
Bonus if the answer can be a one-liner variable-assignment.