Re: awk fields



On Wednesday 01 September 2010 22:32 in comp.unix.shell, somebody
identifying as Janis Papanagnou wrote...

Am 30.08.2010 19:06, schrieb Ed Morton:

On 8/30/2010 10:59 AM, Seebs wrote:

On 2010-08-30, contracer<contracer11@xxxxxxxxx> wrote:

cat tapes.lis | awk ' { if ($15=8) { print $0 }}'

This seems gratuitously complicated. Try:

awk '$15 = 8'

Unlike shell, "=" is an assignment, "==" is a test:

Sorry to nit-pick. As in shell, "=" is an assignment.
"==" is also the equality test in modern shells, in
addition to the old "=", which may even be deprecated
(as in Kornshell).

You may consider it deprecated - and in all fairness, so do I - but a
single "=" as an equality test is still the official POSIX standard,
while "==" is not. ;-)

GNU Bash supports both "=" and "==" as equality tests, by the way.
Don't know about the Korn Shell or the C Shell as I use neither.

--
*Aragorn*
(registered GNU/Linux user #223157)
.



Relevant Pages

  • Re: awk fields
    ... identifying as Janis Papanagnou wrote... ... awk '$15 = 8' ... (as in Kornshell). ... Don't know about the Korn Shell or the C Shell as I use neither. ...
    (comp.unix.shell)
  • Re: Which shell?
    ... One issue with the Korn shell is that Sun actually supplies two ... on the latter ["The New KornShell Command And Programming Language", ... bunch of graphics primitives built in ["Desktop Kornshell Graphical ...
    (comp.unix.solaris)
  • Re: Newbie Scripting Variable Question
    ... A lot of scripters use the single back quotes to indicate a command ... The cal is evauated, the output used as input for awk, and then the awk ... is the Korn Shell by David Korn. ... # typeset -Z2 abc ...
    (comp.unix.aix)
  • Re: Newbie Scripting Variable Question
    ... A lot of scripters use the single back quotes to indicate a command ... assign it to PDAY. ... The cal is evauated, the output used as input for awk, and then the awk ... is the Korn Shell by David Korn. ...
    (comp.unix.aix)