Using awk with rsh

der Mouse mouse at thunder.mcrcim.mcgill.edu
Sat Jun 22 18:44:55 AEST 1991


In article <1991Jun19.143911.22217 at rodan.acs.syr.edu>, mitanu at 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 at larry.mcrcim.mcgill.edu



More information about the Comp.unix.questions mailing list