A system administrator needs to find all lines within '/var/log/syslog' that contain either 'error' or 'failed'. The administrator decides to use a command that supports regular expressions to accomplish this task. Which command will correctly output the desired lines?
The command 'egrep "error|failed" /var/log/syslog' uses regular expressions to search for lines that match either 'error' or 'failed'. Here, the pipe '|' character serves as a logical OR operator in the regular expression. The use of double quotes allows the pipe character to be interpreted correctly by the shell as part of the egrep command's pattern argument.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is egrep and how does it differ from grep?
Open an interactive chat with Bash
What are regular expressions and why are they important?
Open an interactive chat with Bash
What is the significance of the '| (pipe)' character in the regular expression used?