Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #178447
| From | Richard Owlett <rowlett@cloud85.net> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Recomended tutoial(s) on doing arithmetic in Bash scripts |
| Date | 2017-03-05 19:20 +0100 |
| Message-ID | <thIVb-49C-9@gated-at.bofh.it> (permalink) |
| References | <thGA1-2jU-5@gated-at.bofh.it> <thHcJ-2Sl-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 03/05/2017 10:25 AM, tomas@tuxteam.de wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Sun, Mar 05, 2017 at 09:42:16AM -0600, 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.
>[snip]
>
> If you need floating point numbers, bc (or dc) are your next stops.
Actually dc is the solution.
I date from Byte's FORTH issue. Benn a fan ever since.
>
> Perhaps you start with a couple of small examples on what you want
> to achieve, post them here and we take them as riddles :-)
How about the whole app <grin>
You solved my problem with one line.
The so called tutorial on dc went to great length to make it look like
paper coming out of a desk calculator that it obliterated any
information. Discouraged me from even looking at the man page.
>
> Here's a little example with dc, [snip]
>
> If you wanted to catch the value instead of printing it right away,
> you would do
> fill=$(dc -e "5k $NOW $FULL / p")
That's the hint I needed <*GRIN*>
I needed to report the number of bytes downloaded for each portion of a
project. My 1st pass is below. [I messed up something when I tried to
divide by 1024 to get kb. Symptom was I somehow had a bad value on the
stack]
mystring=$(echo $(grep "usb0" /proc/net/dev))
read -r -a myarray <<<$mystring
owl1=${myarray[1]}
echo $owl1
# insert process to be measured
mystring=$(echo $(grep "usb0" /proc/net/dev))
read -r -a myarray <<<$mystring
owl2=${myarray[1]}
echo $owl2
bytes=$(dc -e "1k $owl2 $owl1 - p ")
echo "You have just downloaded " $bytes " bytes"
Someone on another group wanted me to use LibreOffice Calc ;/
Thanks
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Recomended tutoial(s) on doing arithmetic in Bash scripts Richard Owlett <rowlett@cloud85.net> - 2017-03-05 16:50 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Reco <recoverym4n@gmail.com> - 2017-03-05 17:30 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-05 17:30 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts GiaThnYgeia <GiaThnYgeia@openmailbox.org> - 2017-03-05 19:20 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-05 21:40 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Greg Wooledge <wooledg@eeg.ccf.org> - 2017-03-06 14:40 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-06 15:00 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Jörg-Volker Peetz <jvpeetz@web.de> - 2017-03-06 16:00 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-06 16:40 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Richard Owlett <rowlett@cloud85.net> - 2017-03-05 19:20 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Richard Owlett <rowlett@cloud85.net> - 2017-03-05 19:50 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-05 21:30 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Richard Owlett <rowlett@cloud85.net> - 2017-03-05 22:00 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Jude DaShiell <jdashiel@panix.com> - 2017-03-05 23:20 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Richard Owlett <rowlett@cloud85.net> - 2017-03-06 12:20 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-06 12:40 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts David Christensen <dpchrist@holgerdanske.com> - 2017-03-05 20:50 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Richard Owlett <rowlett@cloud85.net> - 2017-03-05 21:50 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts David Christensen <dpchrist@holgerdanske.com> - 2017-03-06 04:40 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts <tomas@tuxteam.de> - 2017-03-05 22:30 +0100
Re: Recomended tutoial(s) on doing arithmetic in Bash scripts Jude DaShiell <jdashiel@panix.com> - 2017-03-05 23:10 +0100
csiph-web