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 the difference between 'grep' and 'egrep'?
Open an interactive chat with Bash
What does the pipe '|' do in regular expressions?
Open an interactive chat with Bash
Why are double quotes used around the pattern in the command?