Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!att!ucbvax!ARCO.COM!dprclf From: dprclf@ARCO.COM ("Chris L. Fouts") Newsgroups: comp.sys.sgi Subject: Re: awk vs echo Message-ID: <9102111856.AA27240@phobos> Date: 11 Feb 91 18:56:43 GMT References: <9102111145.aa01900@VGR.BRL.MIL> Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 60 In message <9102111145.aa01900@VGR.BRL.MIL>; "Peter Jaspers-Fayer" writes: > I guess that even after a year of trying, I do not understand the way > the shell (csh) passes things to it's children, viz: > > This is an excerpt from a longer awk command, and I'm stuck: > > This works > awk '{ print "'$user': " $0}' > as does > awk '{ print "'`hostname`': " $0}' > But not > awk '{ print "'`date`': " $0}' (Spaces(?) Colons(?)) > Even tho > echo '{ print "'`date`': " $0}' works OK, and if I CUT&PASTE > the result of the echo into another awk '', something like: > > awk '{ print "Mon Feb 11 11:35:32 EST 1991: " $0}' IT WORKS! > > Why are the last and 2nd-last awks different? Anyone please? The first awk winds up as awk '{ print "'Mon Feb 11 11:35:32 EST 1991': " $0}' which has the awk program spread across multiple arguments as highlighted below: awk '{ print "'Mon Feb 11 11:35:32 EST 1991': " $0}' ^^^^^^^^^^^^^^ ^^^ ^^ ^^^^^^^^ ^^^ ^^^^^^^^^^^^^ = 6 args whereas awk '{ print "Mon Feb 11 11:35:32 EST 1991: " $0}' has the awk program in only 1 argument. To accomplish what you want (get ready for yet more quotes), try: awk '{ print "'"`date`"': " $0}' ^ ^ | | +------+----These quotes prevent the spaces in the date output from splitting up the argument. My head starts hurting if I look at this too long.... -- Chris L. Fouts Email: dprclf@phobos Ext: 3850 "Fate is the path of least action." -- Kim Stanley Robinson in "A Short, Sharp Knock" "Every day, I sit in traffic and consider my fate...."