Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #178462
| 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 22:00 +0100 |
| Message-ID | <thLq1-5IO-15@gated-at.bofh.it> (permalink) |
| References | <thGA1-2jU-5@gated-at.bofh.it> <thHcJ-2Sl-3@gated-at.bofh.it> <thIVb-49C-9@gated-at.bofh.it> <thKWZ-5yk-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 03/05/2017 02:23 PM, tomas@tuxteam.de wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Sun, Mar 05, 2017 at 12:10:43PM -0600, Richard Owlett wrote: > > [...] > >> How about the whole app <grin> >> You solved my problem with one line. > > Glad it helped :) > > [...] > >> I needed to report the number of bytes downloaded for each portion >> of a project [...] > > Let me pick a nit... > >> mystring=$(echo $(grep "usb0" /proc/net/dev)) > > This should be equivalent to > > mystring=$(grep "usb0" /proc/net/dev) I was just copying the tutorial's syntax. I had no explanations, only code fragments. One of the sites that prompted me to ask for recommendations. > > (background: > > - grep "usb0"/proc/net/dev > spits out the line(s) containing the pattern "usb0" > > - the $(...) around it expands it in the shell inline > > - the echo spits that again out to stdout > > - the $(...) around it expands it again in-line > > So unless the expansion is doing anything funky (which we won't hope, > but see below), you can unwrap the outer $(echo ...). > > Now the second nit: I'm not sure whether there's a case when the > unquoted $(...) might undergo a further expansion by the shell, > so it's prudent to quote it, like so: > > mystring="$(grep "usb0" /proc/net/dev)" > > (I know, my example wasn't... exemplar in this respect, but I knew > I was only getting plain numbers and I was kind of lazy: bad tomás) > >> Someone on another group wanted me to use LibreOffice Calc ;/ > > Might work, but don't ask me how :-/ That poster's explanation made little sense. Only one of the reasons I didn't try it.
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