SysV echo

Govind N. Kamat kamat at uceng.UC.EDU
Thu May 18 11:22:54 AEST 1989


In article <17548 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:

+ There is a solution (albeit ugly):
+ 
+ 	cat << end
+ 	$foo
+ 	end
+ 
+ but you may need to do something more.  To keep echo from munching away
+ backslashes, you might do this:
+ 
+ 	qfoo=`cat << end | sed 's/\\\\/\\\\\\\\'
+ 	$foo
+ 	end`
+ 
+ except that, due to vagaries of Bourne's implementation, it does not work.
+ (It might work in ksh.) ...

The following works okay in both Bourne and Korn shells on our machine
(HP-UX, which is basically SVR2):

foo='a\b\\c\\\d\\\\e\\\\\f'
qfoo=$foo
cat <<-EOF
	$qfoo
EOF

On ksh, one can use the raw option of echo, echo -r instead.
-- 
Govind N. Kamat				College of Engineering
kamat at uceng.UC.EDU			University of Cincinnati
					Cincinnati, OH 45221, USA



More information about the Comp.unix.questions mailing list