Awk Programming Question:

Download Job Interview Questions and Answers PDF

The command "awk '{if ("9″>"10″) print "google" else print "linux"}'"
a) will print "google"
b) will print "linux"
c) will generate syntax error
d) none of the mentioned

Awk Programming Interview Question
Awk Programming Interview Question

Answer:

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#

Download Awk Programming Interview Questions And Answers PDF

Previous QuestionNext Question
What is expression in awk programming?
a) expression evaluates a value to print, test or pass to a function
b) expression assigns a new value to a variable or field
c) both (a) and (b)
d) none of the mentioned
What is the output of this program?

#! /usr/bin/awk -f
BEGIN {
a=0
do {
print "google"
a++
} while (a<5)
}
a) "google" will print 4 times
b) "google" will print 5 times
c) nothing will print
d) syntax error