🎴 Flashcard Mode

Basic Unix Commands Quiz

Card1 / 10
Mastered0
Review0
QuestionClick to flip

Which symbol will be used with grep command to match the pattern pat at the beginning of a line?

AnswerClick to flip back
A
^pat
💡 Explanation:

To match the pattern "pat" at the beginning of a line using the grep command, the symbol ^ will be used.

Now let's go through each option and explain why it is right or wrong:

A. ^pat: This option is correct. The ^ symbol in a regular expression is used to match the pattern at the beginning of a line. Therefore, ^pat will match the pattern "pat" at the beginning of a line.

B. $pat: This option is incorrect. The $ symbol in a regular expression is used to match the pattern at the end of a line. Therefore, $pat will match the pattern "pat" at the end of a line, not at the beginning.

C. pat$: This option is incorrect. The $ symbol in a regular expression is used to match the pattern at the end of a line. Therefore, pat$ will match the pattern "pat" at the end of a line, not at the beginning.

D. pat^: This option is incorrect. The symbol ^ does not have any special meaning when it appears after the pattern. Therefore, pat^ will match the literal string "pat^" rather than the pattern "pat" at the beginning of a line.

The Answer is: A. ^pat

Change Mode