What is the output of the program? [code] #! /usr/bin/awk -f #This filename is text.awk BEGIN { print FILENAME }[/code]

What is the output of the program?
Code:
   #! /usr/bin/awk -f
   #This filename is text.awk
   BEGIN {
       print FILENAME
   }
A. test.awk
B. program will print nothing
C. syntax error
D. fatal error
 
Answer: b
Explanation: The built-in variable FILENAME is the name of file that awk is currently reading and in this program there is no file listed on the command line.
Output:
root@ubuntu:/home/123hoidap# ./test.awk
root@ubuntu:/home/123hoidap#
 

Tìm kiếm

Back
Top