NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Invoking bc with defaults



herbert langhans <w3%langhans.com.pl@localhost> wrote:

> > Create a file  ~/bc.conf with your desired settings (like your
> > mentioned scale=4).
> > Start bc with this file as argument and force interactive mode:
> >   bc -i bc.conf
> > This will evaluate bc.conf and instead of quitting after EOF it will drop 
> > you to
> > a bc prompt for further evaluation.
>
> it works nicely now. I still wonder why bc doesnt have such basic option
> by default - I had never guessed to use it to set this option. The manual
> page says -i is the 'interactive mode' - interactive it is anyway when I
> can type calculations on the command line ...

Just thought I'd point out that you can also pipe options to bc(1); I use
the following shell script as a simple calulator:

  #!/bin/sh
  # calc - uses bc(1) to do math calculations; precision = 4
  # useage:  calc "<math expression>"

  echo "scale=4; $@" | bc -l

You might find that easier than yet having another rc file.

--JW



Home | Main Index | Thread Index | Old Index