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
a) FNR is the current record number in the current file
a) input field seperator
a) match function
a) name of variable
b) we are refering to a field or column in the current line
b) program will print nothing
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/google# ./test.awk
root@ubuntu:/home/google#
a) google
Output:
root@ubuntu:/home/google# ./test.awk
google
root@ubuntu:/home/google#
a) "google" will print 2 times
Output:
root@ubuntu:/home/google# ./test.awk
google
google
root@ubuntu:/home/google#
a) google
Output:
root@ubuntu:/home/google# ./test.awk
google
root@ubuntu:/home/google#
b) 0 2
Output:
root@ubuntu:/home/google# ./test.awk
0
2
root@ubuntu:/home/google#
d) nawk does not provide the additional capabilities in comparison of awk
d) all of the mentioned
Explanation:
The method used to run awk program depends on the program size and input files.
c) both (a) and (b)
d) the number of fields need to be a constant
Explanation:
The number of fields does not need to be a constant.
c) "h" prints an unsigned hexadecimal integer
Explanation:
"x" prints and unsigned hexadecimal integer
b) print the first field of every line in san.txt
a) A
Explanation:
The ASCII value of A is 65.
d) comparison expressions does not compare strings for relationship
a) awk 'BEGIN {print "google"}'
a) writing expressions next to one another, with no operator
a) double precision floating point
a) true
Explanation:
The operands of relational operators are converted to, and compared as string if both are not numbers. Strings are compared by comparing the characters of each. Hence 20 is less then 9.
Output:
root@ubuntu:/home/google# chmod +x test.awk
root@ubuntu:/home/google# ./test.awk
true
root@ubuntu:/home/google#
c) the string x matches the regular expression denoted by y