Linux Regular Expressions Aptitude Questions and Answers

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

This section contains Aptitude Questions and Answers on Linux Regular Expressions.

1) There are the following statements that are given below, which of them are correct about Regular expressions in the Linux operating system?
  1. The regular expressions are strings that are used for pattern matching in some Linux commands.
  2. The regular expressions are also known as a regex.
  3. The regular expressions use some characters that each has a different meaning.
  4. Regular expressions can only be used in the Linux commands.

Options:

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

2) Which of the following command uses regular expressions in the Linux operating system?
  1. grep
  2. sed
  3. rename
  4. bash

Options:

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

3) Which of the following types of regular expressions are used in the Linux operating system?
  1. Basic Regular Expression
  2. Extended Regular Expression
  3. Crond Regular Expression
  4. Perl Regular Expression

Options:

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

4) Which of the following option is used for a basic regular expression in the grep command?
  1. -B
  2. -G
  3. -P
  4. -E

5) Which of the following is used to match any set of characters from the specified file in the grep command?
  1. ()
  2. {}
  3. []
  4. ##

6) Which of the following symbols are used for a regular expression in the Linux?
  1. $
  2. ?
  3. _
  4. +

Options:

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

7) Which of the following symbol is used to match exactly one character?
  1. $
  2. ?
  3. _
  4. +

8) Which of the following symbol is used to match preceding character N times or more than N times?
  1. (N)
  2. (N,)
  3. {N}
  4. {N,}

9) Which of the following symbol is used to represent the group of characters?
  1. /
  2. \
  3. +
  4. -

10) Which of the following symbol is used to group regular expressions?
  1. []
  2. ()
  3. {}
  4. <>

11) Which of the following symbol is used to match the empty string at the edge of a word?
  1. \<
  2. \>
  3. \B
  4. \b

12) Which of the following symbol is used to match the empty string if it is not at the edge of a word?
  1. \<
  2. \>
  3. \B
  4. \E

13) Which exact command is used, when we want to search words in the file that can be "ABC1", "ABC5", and "ABC8"?
  1. grep "ABC[0-9]" <filename>
  2. grep "ABC(0-9)" <filename>
  3. grep "ABC(0-9)" <filename>
  4. grep "ABC(0-9)" <filename>

14) Can we use regular expressions with awk command?
  1. Yes
  2. No

15) Which of the following command is used to display only directories that exist in the current directory?
  1. ls –l | grep "^d"
  2. ls | grep "^d"
  3. ls –l | grep "#d"
  4. ls –l | grep "*d"

16) Which of the following command is used to rename the file names that contain “text” with “txt” in the current directory?
  1. rename 'r/txt/text' *
  2. rename 'e/text/txt' *
  3. rename 's/txt/text' *
  4. rename 's/text/txt' *

17) Which of the following command is used to replace the specific word, for example we want to replace inclusion by exclusion?
  1. echo inclusion | sed 's/in/ex'
  2. echo inclusion | sed 's/ex/in'
  3. echo inclusion | sed 'r/in/ex'
  4. echo inclusion | sed 'R/in/ex'


19) Which of the following symbol is used to match the empty string at the beginning of a word?
  1. \<
  2. \%
  3. \$
  4. \(

20) Can we use regular expressions in VI editor?
  1. Yes
  2. No





Comments and Discussions!

Load comments ↻





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