[clue] arithmetic in bash
David L. Willson
DLWillson at TheGeek.NU
Thu Apr 12 15:28:40 MDT 2012
> David L. Willson writes:
> > Thanks for the well-thought-out answer. I'll return to using
> > '$(( EXPRESSION ))', even though I can depend on bash for all
> > my work.
>
> You're very welcome. I've done some more googling since this morning
> and came across https://wiki.ubuntu.com/DashAsBinSh which is a pretty
> nice document covering differences between Bash and other, more
> strictly POSIX, Bourne family shells. Use of $RANDOM is specifically
> addressed there.
>
> - Aaron
That article is a good illustration of low-cost vs high-cost portability.
Recommending cat'ing /dev/*random over the of $RANDOM. Yuck.
Recommending back-ticks '' over $( COMMAND ). YUCK!
Using $(( )) over $[ ] is trivial. Those other two are moderate and huge, respectively. Both "bash-ism's" increases readability significantly. The bash-ism for command-nesting increases functionality, too.
--
David L. Willson
Trainer, Engineer, Enthusiast
RHCE Network+ A+ Linux+ LPIC-1 Ubuntu
Mobile 720-333-LANS(5267)
This is a good time for a r3volution.
More information about the clue
mailing list