Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!icdoc!bilpin!jim From: jim@bilpin.UUCP (Jim G) Newsgroups: comp.unix.questions Subject: Re: Strange behaviour of awk Summary: String functions in awk Keywords: awk Message-ID: <1151@bilpin.UUCP> Date: 6 Mar 89 13:13:35 GMT References: <497@eutrc3.UUCP> Organization: SRL, London, England Lines: 28 #{ v_unix.2 } IN ARTICLE <497@eutrc3.UUCP> , wsinkees@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@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 ) -- Programmers' maxim : If it's not aesthetically pleasing, it's probably wrong.