Question 300
A Linux user needs to resolve this problem: A beginner runs grep '.' data.txt and believes the dot matches only a literal period character. Which specific action BEST resolves the stated problem?
Explanation
Correct Answer
Escape a dot when a literal period is required, for example grep '\.' data.txt. This directly addresses the reported situation. Why it works: An unescaped dot matches an arbitrary character in a basic regular expression. Acceptance evidence: A test line without a period is excluded by the literal-dot search while file.name matches.
Incorrect Answers
This option would change the part of the system described by: Use cut -d: -f1 on the structured file when its delimiter contract is known. The reported behavior instead arises because escape a dot when a literal period is required, for example grep '\.' data.txt. The direct remediation is “Escape a dot when a literal period is required, for example grep '\.' data.txt”.
Use head -n 5 export.txt to read the beginning of the file. That explains why “Use head -n 5 export.txt to read the beginning of the file” is useful for its own dependency, but the present failure follows a different constraint: Escape a dot when a literal period is required, for example grep '\.' data.txt. The targeted correction is “Escape a dot when a literal period is required, for example grep '\.' data.txt”.
“Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available” acts on a neighboring technical dependency: Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available. It does not resolve the stated condition, whose causal mechanism is: Escape a dot when a literal period is required, for example grep '\.' data.txt. The required action is “Escape a dot when a literal period is required, for example grep '\.' data.txt”.