A system administrator of a Linux server is searching the passwd file for the username taylor that appears at the beginning of the line. Which grep command should the administrator use?

IT Questions BankCategory: DevNetA system administrator of a Linux server is searching the passwd file for the username taylor that appears at the beginning of the line. Which grep command should the administrator use?

A system administrator of a Linux server is searching the passwd file for the username taylor that appears at the beginning of the line. Which grep command should the administrator use?

  • grep taylor /etc/passwd
  • grep '.taylor' /etc/passwd
  • grep '^taylor' /etc/passwd
  • grep '[taylor]' /etc/passwd

Explanation: The Linux grep command can be used to process text line by line and to print any lines which match a specified pattern. The matching patterns are based on regular expression (regex) query modifiers used to select the appropriate content. Some regex query modifiers are as follows:
(underscore): matches a space
^ (caret): indicates the start of a string
$ (dollar sign): indicates the end of a string
. (period): matches a single character, including a space
(asterisk): matches zero or more occurrences of the preceding character
(square bracket): matches a character
{ } (curly bracket): repeats preceding character

Exam with this question: 1.2.3 Quiz - Linux Review

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments