Strange behaviour of awk

Jim G jim at bilpin.UUCP
Mon Mar 6 23:13:35 AEST 1989


    #{ v_unix.2 }
    IN 	ARTICLE <497 at eutrc3.UUCP> , wsinkees at eutrc3.UUCP (Kees Huizing)
    WRITES :

    [ stuff deleted ]

>   Now I have two questions:
>   1. How can the value of $0 depend on whether it has been printed or not?
>      Is this a bug, or do I overlook some mechanism of awk?
>   2. Is there a direct way to get $2, $3, .... until the end of the line (record)
>      without the somewhat dirty change of $1?  This was my original problem.

    1. Our version of awk ( UNIX  System V Rel.2:01 ) works correctly here,
       but such assignments cause compression of white space ( multiple
       tabs/spaces between fields become single spaces ), so I would have to
       defer to {dph at lanl.gov (David Huelsbeck)}'s comments on that, as
       regards the specific problem on your system.
    2. A neat way to print from $? to end of line, as long as you are sure 
       that the value of $? will not appear as an earlier field in the line, 
       is : 	
		print substr( $0, index( $0, $? ) )
       ( see Aho/Weinberger/Kernighan's book 'The AWK Programming Language',
         p.42, for a summary of all the string functions )
-- 
			   <Jim G, Hatfield, England>
	   <Path: mcvax!ukc!icdoc!bilpin!jim> <UUCP: jim at bilpin.uucp>
  Programmers' maxim : If it's not aesthetically pleasing, it's probably wrong.



More information about the Comp.unix.questions mailing list