Operating Systems
A technician must display every line in /var/log/syslog that contains the word error, whatever its capitalisation. Which command does this?
Show the answer
Correct answerD. grep -i error /var/log/syslog
AWhy not this: Without -i, grep is case-sensitive and would miss lines containing Error or ERROR.
BWhy not this: tail shows only the last lines of the file, whether or not they contain the word.
CWhy not this: find matches file names, not text inside files, so it cannot show matching log lines.
DWhy this is right: grep searches the lines of the file, and -i ignores case so all capitalisations match.
grep searches file contents for a pattern, and -i makes the match case-insensitive so Error and ERROR are included. Plain grep is case-sensitive, and find only matches file names.