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

Re: Simple calculator



On Wed, Aug 05, 1998 at 07:51:39AM +0200, Dr. Michael Meskes wrote:
> Do bc and dc accept the numbers on the command line?

To an extent:

zylo@zylo:~$ echo '2.2 + 3.3' | bc -l
5.5
zylo@zylo:~$ bc -l <<EOF
> 2.2 + 3.3
> EOF
5.5

Using a wrapper script:

zylo@zylo:~$ cat bc.pl
#!/usr/bin/perl

if ( ! (open BC, "|bc -l") ) { print STDERR "Can't open bc.\n"; exit -1; }
print BC join(' ',@ARGV),"\n";
close BC;
zylo@zylo:~$ ./bc.pl 2.2 + 3.3
5.5

-- 
* Gavin Lewis  zif@kalifornia.com (preferred)                    *
*              zif@hax0r.org      (alias to above, could vanish) *


--  
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: