AWK trivia question 
Author Message
 AWK trivia question

If RS=="", can NF ever equal 0?

I.e., can the following program ever print 0?

BEGIN {RS=""}
{print NF}



Wed, 19 Feb 2003 06:58:27 GMT  
 AWK trivia question

Quote:

>If RS=="", can NF ever equal 0?

>I.e., can the following program ever print 0?

>BEGIN {RS=""}
>{print NF}

It can. The script turns the whole input file into one record.
Just feed it a line with just one or more spaces on it and it
will print 0.

--
  (  Kees Nuyt; Rotterdam; Netherlands

c[_] Disclaimer: Any opinions etc. are mine, not necessarily my employer's.



Wed, 19 Feb 2003 15:14:21 GMT  
 AWK trivia question

Quote:

> If RS=="", can NF ever equal 0?

> I.e., can the following program ever print 0?

> BEGIN {RS=""}
> {print NF}

$ echo ' ' | awk 'BEGIN { RS = "" } { print NF }'
0
$

At last, we agree: This IS trivial!

--
Jim Monty

Tempe, Arizona USA



Thu, 20 Feb 2003 12:09:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Fun trivia question. :-)

2. Minor trivia question

3. Questions for Smalltalk Trivia

4. PLI/Multics trivia question

5. COBOL Programming Style Trivia Question

6. Trivia Question for COBOL Gurus

7. MONTY PYTHON - TRIVIA QUESTIONS REQUESTED

8. Trivia question: sqrt() in Quintus

9. CDC FORTRAN trivia questions

10. Tcl Trivia Question

11. viaweb trivia question

12. TCL TRIVIA QUESTION !

 

 
Powered by phpBB® Forum Software