linux awk_Linux AWK能力倾向问题与解答

linux awk

This section contains Aptitude Questions and Answers on Linux AWK.

本节包含有关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

Answer & Explanation

Correct answer: 3
A, B, and D

Statements A, B, and D are correct about AWK in the Linux operating system.

1)下面给出了以下语句,其中哪些对于Linux操作系统中的AWK是正确的?
  1. AWK是一种脚本语言,用于对数据执行操作并生成报告。

  2. AWK程序不需要编译。

  3. AWK程序需要编译。

  4. 我们可以在AWK程序中使用逻辑运算符,字符串函数和数字函数。

选项:

  1. A和B

  2. A和D

  3. A,B和D

  4. A,C和D

答案与解释

正确答案:3
A,B和D

关于Linux操作系统中的AWK,语句A,B和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

Answer & Explanation

Correct answer: 3
Aho Weinberger Kernighan

The AWK stands for Aho Weinberger Kernighan. The Aho, Weinberger, and Kernighan are the AWK developers.

2)AWK的完整形式是什么?
  1. 主动工作包

  2. 主动井荣誉

  3. Aho Weinberger Kernighan

  4. 安德森·华盛顿·克尼根

答案与解释

正确答案:3
Aho Weinberger Kernighan

AWK代表Aho Weinberger Kernighan。 Aho,Weinberger和Kernighan是AWK开发人员。

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

Answer & Explanation

Correct answer: 4
A, B, C, and D

All given statements are correct about AWK.

3)AWK可以完成以下哪些正确的任务?
  1. 我们可以使用AWK逐行扫描文件。

  2. 它用于转换数据文件。

  3. 用于在匹配的行上执行操作。

  4. 我们可以使用AWK生成格式化的报告。

选项:

  1. A和B

  2. A,C和D

  3. A,B和D

  4. A,B,C和D

答案与解释

正确答案:4
A,B,C和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

Answer & Explanation

Correct answer: 1
awk '/school/ {print}' abc.txt

The 1st command is correct to print only those lines that contain "school" using AWK.

4)假设一个文本文件“ abc.txt”包含多行,其中某些行包含单词“ school”。 然后如何使用AWK仅打印包含“学校”的行?
  1. awk'/ school / {print}'abc.txt

  2. awk -check'/ school / {print}'abc.txt

  3. awk -check'/ school /'abc.txt

  4. 以上都不是

答案与解释

正确答案:1
awk'/ school / {print}'abc.txt

使用AWK仅打印包含“ school”的行的第一命令是正确的。

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

Answer & Explanation

Correct answer: 3
A, B, and D

Options A, B, and D are the correct inbuilt variable in AWK.

5)以下哪些是AWK中的内置变量?
  1. FS

  2. OFS

  3. 肯德基

  4. ORS

选项:

  1. A和B

  2. A,C和D

  3. A,B和D

  4. A,B,C和D

答案与解释

正确答案:3
A,B和D

选项A,B和D是AWK中正确的内置变量。

6) Which of the following is not the inbuilt variable in AWK?
  1. NR

  2. NF

  3. FN

  4. FILENAME

Answer & Explanation

Correct answer: 3
FN

The "FN" is not a valid inbuilt variable in AWK.

6)以下哪个不是AWK中的内置变量?
  1. NR

  2. NF

  3. FN

  4. 文档名称

答案与解释

正确答案:3
FN

“ FN”在AWK中不是有效的内置变量。

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

Answer & Explanation

Correct answer: 2
awk '{print NR,$0}' abc.txt

The 2nd command is correct to print all complete lines with line numbers using AWK.

7)假设一个文本文件“ abc.txt”包含多行,那么如何使用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

答案与解释

正确答案:2
awk'{print NR,$ 0}'abc.txt

第二个命令使用AWK打印带有行号的所有完整行是正确的。

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>

Answer & Explanation

Correct answer: 1
awk 'NR==2, NR==4 {print NR,$0}' <filename>

The 1st command is correct to print lines from 2 to 4.

8)如何使用AWK从第2行到第4行打印给定文本文件的行?
  1. awk'NR == 2,NR == 4 {print NR,$ 0}'<文件名>

  2. awk'NR == 2至NR == 4 {print NR,$ 0}'<文件名>

  3. awk'NR == 2-4 {print NR,$ 0}'<文件名>

  4. awk'NR == 2,4 {print NR,$ 0}'<文件名>

答案与解释

正确答案:1
awk'NR == 2,NR == 4 {print NR,$ 0}'<文件名>

第一条命令正确打印2到4行。

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>

Answer & Explanation

Correct answer: 1
awk 'NF > 0' <filename>

The 1st command is used to print non-empty line. Because the NF variable denotes number of fields in the file.

9)如何使用AWK从给定文件中打印非空行?
  1. awk'NF> 0'<文件名>

  2. awk'NF'<文件名>

  3. awk'NE> 0'<文件名>

  4. awk'NE'<文件名>

答案与解释

正确答案:1
awk'NF> 0'<文件名>

第一个命令用于打印非空行。 因为NF变量表示文件中的字段数。

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>

Answer & Explanation

Correct answer: 3
awk 'END { print NR }' <filename>

The 3rd option is correct, because -12 describes, it do not display 1st and 2nd column.

10)以下哪个命令用于打印指定文件中存在的行数?
  1. awk'END {print NL}'<文件名>

  2. awk'END {print N}'<文件名>

  3. awk'END {print NR}'<文件名>

  4. awk'END {print NN}'<文件名>

答案与解释

正确答案:3
awk'END {print NR}'<文件名>

第三个选项是正确的,因为-12描述,所以它不显示第一列和第二列。

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>

Answer & Explanation

Correct answer: 2
awk '{print $2} <filename>

11)以下哪个命令用于打印指定文件的第三列?
  1. awk'{print $ 3} <文件名>

  2. awk'{print $ 2} <文件名>

  3. awk'{print $ N2} <文件名>

  4. awk'{print $ N3} <文件名>

答案与解释

正确答案:2
awk'{print $ 2} <文件名>

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

Answer & Explanation

Correct answer: 4
Output Field Separator

The "OFS" stands for "Output Field Separator".

12)AWK中OFS的完整形式是什么?
  1. 对象字段分隔符

  2. 过时的字段分隔符

  3. 专用现场分隔符

  4. 输出场分隔符

答案与解释

正确答案:4
输出场分隔符

“ OFS”代表“输出字段分隔符”。

13) Which of the following is known as match operator in AWK?
  1. =

  2. !

  3. ~

  4. ==

Answer & Explanation

Correct answer: 3
~

The tilde is known as a match operator in AWK.

13)以下哪项被称为AWK中的匹配运算符?
  1. =

  2. ==

答案与解释

正确答案:3

代字号在AWK中称为匹配运算符。

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

Answer & Explanation

Correct answer: 2
FILENAME

The FILENAME variable contains the name of the specified file in the AWK command.

14)使用以下哪个内置变量,其中包含AWK命令中指定文件的名称?
  1. 名称

  2. 文档名称

  3. FNAME

  4. FN

答案与解释

正确答案:2
文档名称

FILENAME变量包含AWK命令中指定文件的名称。

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

Answer & Explanation

Correct answer: 1
Output Record Separator

The "ORS" stands for "Output Record Separator".

15)AWK中ORS的完整形式是什么?
  1. 输出记录分隔符

  2. 输出记录符号

  3. 输出恢复符号

  4. 对象记录分隔符

答案与解释

正确答案:1
输出记录分隔符

“ ORS”代表“输出记录分隔符”。

翻译自: https://www.includehelp.com/linux/awk-aptitude-questions-and-answers.aspx

linux awk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值