Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.shell Subject: Re: command substitution Message-ID: <27538@mimsy.umd.edu> Date: 8 Nov 90 06:50:14 GMT References: <5697@alpha.cam.nist.gov> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 41 In article <5697@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: >I want to write the following independent statements into one line: > >set tmp= `awk '{print $7}' /tmp/process.$$` >set date = `basename $tmp` Since your syntax above is C shell (and incorrect C shell at that---the first line sets the variable tmp to nothing, and sets the variable whose name is produced by the awk command to nothing), the answer is `there is no way to do it'. In sh, it is easy: date=`basename \`awk '{print $7}' /tmp/process.$$\`` >I really want to do the following: > >set date = `basename `awk '{print $7}' /tmp/process.$$`` > >Unfortuantly, the second set of Grave accent marks for command >substitution for the basename command will confuse the shell. Well no; actually, their main function is to confuse *you*. :-) They simply close the others. This is: run "basename" run "" splice output from basename and "" onto both ends of the awk set date to the result. >Is there a way to "qoute" these so that those grave accent (`) >will be passed down for another layer command substitution? No; the C shell internals make this impossible. (There are several places that assume that backquote expansion happens only to a depth of one.) If you somehow manage to trick the `scanner' all you will get is a broken shell. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris