sh(1) command substitution and here documents

Jack Nelson jack at cadre.dsl.PITTSBURGH.EDU
Mon Jun 20 05:48:20 AEST 1988


The following shell script prints out 0.75 on a line and ends, which 
seems to follow the sh(1) manual.
	#!/bin/sh
	bc <<End
	scale = 2
	3 / 4
	End

What I would like to do is incorporate this calculation result into a shell
variable using the here document:
	#!/bin/sh
	var=`bc <<End
	scale=2
	3 / 4
	End
	`
But this doesn't work; an error message "cannot open /tmp/sh01383"
always is produced, both on 4.3 and 2.10 systems.  Is there a way
to do this?  Can one deduce this behavior from the manual?
I ended up using a one-line perl script; I suppose awk would work just as
well.  Expr(1) won't do floats.
-- 
John P. Nelson, M.D., 3811 O'Hara St, Pittsburgh, PA 15213, t:412-624-1769 Dept. of Psychiatry, U. of Pittsburgh
UUCP: { akgua | allegra | cmcl2 | idis | ihnp4 | mi-cec | pitt | psuvax1 | sun | sunrise | vax135 } ! cadre ! jack
ARPA: jack at cadre.dsl.pittsburgh.edu



More information about the Comp.unix.wizards mailing list