Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!eos!labrea!decwrl!pyramid!prls!mips!koblas From: koblas@mips.COM (David Koblas) Newsgroups: comp.unix.questions Subject: Re: Floating-Point Arithmetic in a Csh Script Message-ID: <2042@giant.mips.COM> Date: 18 Apr 88 00:23:56 GMT References: <1748@ut-emx.UUCP> Reply-To: koblas@giant.UUCP (David Koblas) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 24 In article <1748@ut-emx.UUCP> you write: >I am trying to do floating-point arithmetic in a csh script for 4.3 BSD. >Since "@ x = 2.3 + 4.5" won't work, I'm using bc. >But I can't find a nice way to get bc's output into a shell variable >without using a temporary file. > >This method does not work: > #!/bin/csh > set x = `bc << END` > scale = 5 > $1 + $2 > END > You were very close, what you needed to do was something more like this: #!/bin/csh set x = `bc << END \ scale = 5 \ $1 + $2 \ END` echo $x -- name : David Koblas place: MIPS Computers Systems phone: 408-991-0287 uucp : {ames,decwrl,pyramid,prls}!mips!koblas