Rich Shepard wrote:
BEGIN {FS="|";OFS="|"}
if {$8!=""} {
      print $0
   }
Awk programs are a collection of
      pattern {action}
an expression like    if ($8 != "") { print $0 }
is a statement, (something that goes in an action, with the pattern omitted
actions are wrapped in curly braces, so one would write something like
{if ($8 != "") {
    print $0
   }
}
also, note that the expression the if is testing is wrapped with parenthesis, not curly braces. or of course, instead of omitting the pattern, you could make the pattern be the condition
being tested, and the action being to print the line.
   pattern: $8 != ""
   action: print $0
and write
$8 != "" { print $0 }

and the $0 is redundant, as {print}  does the same thing
or leave out the whole { print $0} as that's the default action if none is specified

Now if your going for what I think you said originally, values in all 8 fields, the simplest form is
to detect one or more fields being blank and printing those lines is
$1==""||$2=="" || $3=="" || $4=="" || $5=="" || $6=="" || $7=="" || $8==""
as if the action is missing printing the line is done by default.

Of course if your doing more complex processing, rather than simply, check
that all 8 fields contain data, you may want to create  some pattern {action} lines
w/o using the defaults.
steve

Reply via email to