Fresh Awk Programming Interview Questions & Answers:
c) will generate syntax error
Explanation:
Semicolon is required just before the else statement to parse the statement.
Output:
root@ubuntu:/home/google# awk '{if ("9″>"10″) print "google" else print "linux"}'
awk: {if ("9″>"10″) print "google" else print "linux"}
awk: ^ syntax error
root@ubuntu:/home/google#
b) "google" will print 5 times
Output:
root@ubuntu:/home/google# ./test.awk
google
google
google
google
google
root@ubuntu:/home/google#
a) 0,2,4 will print
Output:
root@ubuntu:/home/google# ./test.awk
0
2
4
root@ubuntu:/home/google#
d) "google" will print only 1 time
Explanation:
Even the condition is false of do-while loop, the body is executed once.
Output:
root@ubuntu:/home/google# ./test.awk
google
root@ubuntu:/home/google#
a) nothing will print
Explanation:
The condition of while statement is false so commands inside the loop will not execute.
Output:
root@ubuntu:/home/google# ./test.awk
root@ubuntu:/home/google#
c) both (a) and (b)
d) all of the mentioned
a) its value is used as the exit status code for the awk process
https://InterviewQuestionsAnswers.ORG.