[lug] Letting Bash do the Arithmetic

Sean Reifschneider jafo at tummy.com
Tue Apr 15 13:17:24 MDT 2003


On Mon, Apr 14, 2003 at 06:28:22PM -0600, Peter Hutnick wrote:
>So I'm trying stuff like "head -n ((23945837-4926402)) some.file"  and
>getting "bash: syntax error near unexpected token `('."

I usually use:

   guin:jafo$ echo head -n $[23945837-4926402] some.file
   head -n 19019435 some.file

though I've also been known to do:

   guin:jafo$ let lines=23945837-4926402
   guin:jafo$ echo head -n $lines some.file
   head -n 19019435 some.file

Sean
-- 
 Peppermint Patty gets a DSL line in "YOU'D TELL ME IF YOU WERE IN A GERMAN
 SCHEISSE VIDEO WOULDN'T YOU, CHARLIE BROWN"
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin



More information about the LUG mailing list