Re: Recomended tutoial(s) on doing arithmetic in Bash scripts
- Date: Sun, 5 Mar 2017 22:19:42 +0100
- From: <tomas@xxxxxxxxxx>
- Subject: Re: Recomended tutoial(s) on doing arithmetic in Bash scripts
-----BEGIN PGP SIGNED MESSAGE-----
On Sun, Mar 05, 2017 at 11:48:47AM -0800, David Christensen wrote:
> On 03/05/2017 07:42 AM, Richard Owlett wrote:
> >I'm interested in "expr" and "bc".
> >The man pages lack reasonable examples.
> >The tutorial/HOWTO pages confuse the issue with fancy page layouts
> >and/or code samples showing how impressive the author can make the
> >script's output.
> >Suggestions please.
Perl's a nice language. But *if* you are doing things in shell and
just need to reach out to a small util to do a small thing (The
Shell Way, so to speak) you are better off with small utilities:
tomas@rasputin:~$ time dc -e "2 2 + p"
tomas@rasputin:~$ time perl -e "print 2 + 2"
Of course, if your program becomes complicated, Perl (or Guile, or
Python, or Lua or what not) will be a better choice: lexical variables,
a module system, closures, objects, all the kaboodle.
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
-----END PGP SIGNATURE-----