Linux AWK Aptitude Questions and Answers

Linux AWK Aptitude Questions and Answers: This section contains aptitude questions and answers on Linux AWK.
Submitted by Nidhi, on May 07, 2020

This section contains Aptitude Questions and Answers on Linux AWK.

1) There are the following statements that are given below, which of them are correct about AWK in the Linux operating system?
  1. AWK is a scripting language, which is used to perform operations on data and generate reports.
  2. The compilation is not required for AWK programs.
  3. The compilation is required for AWK programs.
  4. We can use logical operators, string functions, and numeric functions in AWK programs.

Options:

  1. A and B
  2. A and D
  3. A, B, and D
  4. A, C, and D

2) What is the full form of AWK?
  1. Active Working Kit
  2. Active Well Kudos
  3. Aho Weinberger Kernighan
  4. Anderson Washington Kernighan

3) Which of the following correct tasks that can be done by AWK?
  1. We can scan a file line by line using AWK.
  2. It is used to transform data files.
  3. It is used to perform operations on matched lines.
  4. We can produce formatted reports using AWK.

Options:

  1. A and B
  2. A, C, and D
  3. A, B, and D
  4. A, B, C, and D

4) Suppose that a text file "abc.txt" that contains multiple lines, some of the line contains word "school". Then how to print only those line who contains "school" using AWK?
  1. awk '/school/ {print}' abc.txt
  2. awk -check '/school/ {print}' abc.txt
  3. awk -check '/school/ ' abc.txt
  4. None of the above

5) Which of the following are the inbuilt variables in AWK?
  1. FS
  2. OFS
  3. KFS
  4. ORS

Options:

  1. A and B
  2. A, C, and D
  3. A, B, and D
  4. A, B, C, and D

6) Which of the following is not the inbuilt variable in AWK?
  1. NR
  2. NF
  3. FN
  4. FILENAME

7) Suppose that a text file "abc.txt" that contains multiple lines, then how to print all complete lines with line numbers using AWK?
  1. awk '{print NS,$1}' abc.txt
  2. awk '{print NR,$0}' abc.txt
  3. awk '{print NR,$1}' abc.txt
  4. awk '{print NS,$1}' abc.txt

8) How to print lines of a given text file from line number 2 to 4 using AWK?
  1. awk 'NR==2, NR==4 {print NR,$0}' <filename>
  2. awk 'NR==2 to NR==4 {print NR,$0}' <filename>
  3. awk 'NR==2-4 {print NR,$0}' <filename>
  4. awk 'NR==2,4 {print NR,$0}' <filename>

9) How to print non-empty line from the given file using AWK?
  1. awk 'NF > 0' <filename>
  2. awk 'NF' <filename>
  3. awk 'NE > 0' <filename>
  4. awk 'NE' <filename>

10) Which of the following command is used to print the number of lines that exist in the specified file?
  1. awk 'END { print NL }' <filename>
  2. awk 'END { print N }' <filename>
  3. awk 'END { print NR }' <filename>
  4. awk 'END { print NN }' <filename>

11) Which of the following command is used to print the 3rd column of a specified file?
  1. awk '{print $3} <filename>
  2. awk '{print $2} <filename>
  3. awk '{print $N2} <filename>
  4. awk '{print $N3} <filename>

12) What is the full form of OFS in AWK?
  1. Object Field Separator
  2. Obsolete Field Separator
  3. Officiated Field Separator
  4. Output Field Separator

13) Which of the following is known as match operator in AWK?
  1. =
  2. !
  3. ~
  4. ==

14) Which of the following built-in variable is used that contains the name of the specified file in the AWK command?
  1. NAME
  2. FILENAME
  3. FNAME
  4. FN

15) What is the full form of ORS in AWK?
  1. Output Record Separator
  2. Output Record Symbol
  3. Output Resumed Symbol
  4. Object Record Separator





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.