[ILUG] [Possibly OT] Network Traffic Analysis and InterfaceControl

Brian Foster blf at blf.utvinternet.ie
Thu Feb 23 18:58:53 GMT 2006


  | Date: Thu, 23 Feb 2006 13:59:08 -0000
  | From: "Hamilton, David (TSG C&I)" <david.hamilton3 at hp.com>
  | Errors-To: ilug-bounces at linux.ie
  |[ ... ]
  |    tethereal ... | tail -6 | head -5 | awk ... | (tr ',\n' + && echo 0) | bc

 well, if yer using awk(1), you don't need to use head(1),
 tail(1), or Pádraig's trick for using bc(1) with yer output;
 `awk' is perfectly capable of selecting lines and fields
 within lines, adding them together, and printing the sum.

  | -----Original Message-----
  | Sent: 23 February 2006 13:36
  | From: Pádraig Brady
  | 
  |[ ... ] if you want to add the numbers from the shell:
  | 
  |    tethereal ... | (tr '\n,' + && echo 0) | bc

 the numbers, provided they are integers (decimal?),
 can also be added by the GNU bash(1) shell itself,
 by `eval'ing a slightly tricky variable subsistion:

x=$( echo '1,2,3
4,5,6' )    # $x contains simluated  tetherreal ...
            #  replace echo ... with tetherreal ...

eval $'y=$(( ${x//[,\n]/+} ))'  # add, result in $y

echo $y     # print the sum ($y)

 of course, tweaking the  tetherreal ...  output
 so it's easier to process is a rather good idea.

 shell scripts are easy.  ;-)

cheers!
	-blf-
-- 
Experienced (20+ yrs) kernel/software Eng: | Brian Foster   Montpellier,
 • Unix, embedded, &tc;  • Linux;  • doc;  | blf at utvinternet.ie   FRANCE
 • IDL, automated testing, process, &tc.   |  Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie  |     http://www.stopesso.com



More information about the ILUG mailing list