[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Recomended tutoial(s) on doing arithmetic in Bash scripts



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Mar 06, 2017 at 03:50:06PM +0100, Jörg-Volker Peetz wrote:
> Greg Wooledge wrote on 03/06/17 14:38:
> > On Sun, Mar 05, 2017 at 05:25:49PM +0100, tomas@tuxteam.de wrote:
> >> If you need floating point numbers, bc (or dc) are your next stops.
> > 
> > Or awk.  For some problems, awk is fantastic.
> > 
> 
> Yes, it helps to sample the number of "bytes" like so:
> 
> owl1=$(awk '/usb0/ {print $2}' /proc/net/dev)
> 
> # insert process to be measured
> 
> bytes=$(awk "/usb0/ {print (\$2 - $owl1)}" /proc/net/dev)

Yep to Greg and thanks to Jörg. And to those who say "Perl": again,
I'm a Perl fan, but awk is *much* nimbler than Perl and thus far a
better match as a toolset utility in a shell script's context.

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAli9gY0ACgkQBcgs9XrR2kbDGACfZtsUq5bC0pgLDZsESy/NHCoa
mGkAnRabjRPiwTT2EERjVq5PUCnXyD2J
=cyV9
-----END PGP SIGNATURE-----


Reply to: