Date: Tue, 2 Jul 2002 01:05:53 -0500 From: Bob Willcox <bob@immure.com> To: questions list <freebsd-questions@freebsd.org> Subject: awk getline question/odditiy Message-ID: <20020702060553.GA72170@luke.immure.com>
next in thread | raw e-mail | index | archive | help
I noticed tonight that awk (this includes gawk, nawk, and mawk) won't re-execute a command once it has run it once. For example this simple program (called exmpl later on): #!/usr/bin/awk -f { while ($0 | getline line > 0) print line } Running the program with some simple input you get: bob@luke:pl /home/bob/work/local/src/linux_dbg> ./exmpl ps -T PID TT STAT TIME COMMAND 37977 pl Ss 0:00.19 ksh 72370 pl S+ 0:00.03 /usr/bin/awk -f ./exmpl 72377 pl S+ 0:00.00 sh -c ps -T 72378 pl R+ 0:00.00 ps -T ps -T ps -T PID TT STAT TIME COMMAND 37977 pl Ss 0:00.19 ksh 72370 pl S+ 0:00.03 /usr/bin/awk -f ./exmpl 72377 pl Z+ 0:00.00 (sh) 72389 pl S+ 0:00.02 sh -c ps -T 72390 pl R+ 0:00.01 ps -T Notice that the second attempt to run "ps -T" produces no output whereas specifying it as "ps -T" (two spaces between the command and flag) causes it to run. I tried a number of combinations and awk was consistent in _never_ executing the exact same command string more than once. Is there some way to override this behavior? I couldn't find any mention of it in the man page or "The Awk Programming Language" by Aho, Kernighan, & Weinberger. Thanks, Bob -- Bob Willcox Vital papers will demonstrate their vitality by bob@vieo.com spontaneously moving from where you left them to where Austin, TX you can't find them. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020702060553.GA72170>