Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: comp.unix.questions Subject: Re: Using awk with rsh Keywords: awk, rsh Message-ID: <1991Jun22.084455.20177@thunder.mcrcim.mcgill.edu> Date: 22 Jun 91 08:44:55 GMT References: <9105241726.AA16913@?lri.uwo.ca> <49494@ut-emx.uucp> <1991Jun19.143911.22217@rodan.acs.syr.edu> Organization: McGill Research Centre for Intelligent Machines Lines: 32 In article <1991Jun19.143911.22217@rodan.acs.syr.edu>, mitanu@goedel.top.cis.syr.edu (Mitanu Paul) writes: > rsh spica "ps -l | awk '{ print $4}'" I've seen several fixes posted, but none that actually explain what's going on. So here goes.... The problem is that the $4 is being interpreted locally. This is a consequence of the quoting rules: while it's true that $ syntax isn't processed inside single-quoted text, those single quotes don't cause the text between them to be single-quoted, because they are themselves quoted by the double quotes. (On spica, of course, the whole string gets another parse, and this time the single-quotes *do* cause the stuff between them to be single-quoted...but by that time the $4 has already been replaced with whatever $4 was on the source machine.) Thus, it's as if you'd said rsh spica "ps -l | awk '{ print }'" which of course explains the result. With this in hand, you should be able to deduce your own fix, or see why the various posted ones work...the working ones, that is! (Which in this case is most of them, perhaps even all (I haven't been paying close attention).) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu