1. Which one of the following is not true?
a) nawk is the new version of awk
b) gawk is the GNU version of awk
c) linux users have the gawk
d) nawk does not provide the additional capabilities in comparison of awk
View Answer
Explanation: None.
2. An awk program can be run by
a) including the program in the command that runs awk
b) putting it into a file and run with a command
c) running an executable awk script
d) all of the mentioned
View Answer
Explanation: The method used to run awk program depends on the program size and input files.
3. Which one of the following is not true?
a) in typical awk program, all input is read either from standard input or specified files
b) awk language divides its input into records and fields
c) awk reads an input record and the record is automatically seperated by the interpreter into pieces called “fields”
d) the number of fields need to be a constant
View Answer
Explanation: The number of fields does not need to be a constant.
4. What is the meaning of $ sign in awk programming?
a) the word following is the name of variable
b) we are refering to a field or column in the current line
c) $ sign is used for comment
d) none of the mentioned
View Answer
Explanation: None.
5. In awk program, the statement “print” with no items
a) is equivalent to “print $0”
b) prints the entire current record
c) is equivalent to “print $0” & prints the entire current record
d) none of the mentioned
View Answer
Explanation: None.
6. The print and printf statements can be told to send their output to other place except standard output, is called
a) redirection
b) redistribution
c) reinsertion
d) none of the mentioned
View Answer
Explanation: None.
7. The command “awk {print $1} san.txt” will
a) print the first line of file san.txt
b) print the first field of every line in san.txt
c) generate syntax error
d) none of the mentioned
View Answer
Explanation: None.
8. What is the output of the command awk ‘BEGIN {printf “%c\n”,65}’
a) A
b) 65
c) syntax error
d) none of the mentioned
View Answer
Explanation: The ASCII value of A is 65.
9. Which one of the following statement is not true about the format-control letters for printf statement in awk program?
a) “c” prints a number as an ASCII character
b) “d” prints a decimal integer
c) “h” prints an unsigned hexadecimal integer
d) “o” prints an unsigned octal integer
View Answer
Explanation: “x” prints and unsigned hexadecimal integer
10. Which command on the command line provides the same output as this executable awk script?
#! /usr/bin/awk -f
BEGIN {
print "sanfoundry"
}
a) awk ‘BEGIN {print “sanfoundry”}’
b) awk ‘print “sanfoundry”‘
c) awk ‘print {sanfoundry}’
d) none of the mentioned
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – Linux Administration & Programming.
Here’s the list of Best Books in Linux Commands & Shell Programming.
Here’s the list of Best Books in Linux Kernel, Device-Drivers & System Programming.
To practice all questions on Linux Administration & Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on Linux.
- Practice Programming MCQs
- Check Linux Books
- Check Information Technology Books
- Apply for Programming Internship