[lug] Letting Bash do the Arithmetic

Peter Hutnick peter-lists at hutnick.com
Mon Apr 14 18:28:22 MDT 2003


I'm trying to run a command (interactively) and let bash do the grunt
arithmetic for an argument.  I've found several bash guides that are along
the lines "oh, just use the ((expression)) construct.  An example sure
would be nice :-(

So I'm trying stuff like "head -n ((23945837-4926402)) some.file"  and
getting "bash: syntax error near unexpected token `('."

Not what I am looking for.

Any idea why only people writing dead-tree books seem to think that
examples are helpful?  I don't think I have ever seen an actual *working*
example in a man page.  (For reference "foo -x[an integer between -9 and a
gagillion, default is 42][-r][-s][ [-t [/favorite color/ or /pet's
name/][--fast]" is not a working example, as the --fast and -r switches
are mutually exclusive.)

Argh!

-Peter





More information about the LUG mailing list