Help in Understanding awk if ( F ) syntax -

Hi Experts,

I was looking at the below link, for finding words next to it, And unable to understand this syntax:
Can any one please explain , what is meaning of this code:

if ( F )
s = s ? s OFS $i : $i

from:

http://www.unix.com/unix-for-dummies-questions-and-answers/226523-match-pattern-after-certain-pattern-print-words-next-pattern.html

Thanks..

if ( F )
  s = s ? s OFS $i : $i

if expression F is true, then concatenate string 's' with value of field 'i' preceded with the output field separator OFS (if s is not empty). If 's' is empty assign the value of field 'i' to it.
It can be re-written as:

if ( F )
   if (s) 
     s= s OFS $i
   else
     s=$i
1 Like

F can only be true if F is 0 or 1 or has numeric value , is it correct. Thanks..

In awk, A true is defined as if it contains any non-zero numeric value or any non-empty string.

So in your case, if F is not null or not zero then its true.