Difficulty: Easy
Correct Answer: pat$
Explanation:
Introduction / Context:
grep uses basic regular expressions to match text in files or streams. Anchors are special metacharacters that constrain where a pattern must appear in a line. The dollar sign $ anchors the pattern to the line end, and the caret ^ anchors to the line start.
Given Data / Assumptions:
Concept / Approach:
To match “pat” only at the end, write pat$ so that “pat” must immediately precede the end of the line. Using ^pat would instead require “pat” at the beginning. Placing anchors incorrectly or in the wrong order will change the match or render it meaningless.
Step-by-Step Solution:
Verification / Alternative check:
Experiment with ^pat to see it matches only at the start. Combine with character classes or quantifiers as needed, keeping the $ at the end to enforce line-ending.
Why Other Options Are Wrong:
^pat: start-of-line anchor. $pat / pat^: misordered anchors; not meaningful for the intended end-of-line constraint. None of the above: incorrect because pat$ is correct.
Common Pitfalls:
Forgetting that grep patterns are regex, not globbing; neglecting to quote the pattern in the shell to avoid unintended expansions; confusing ^ and $ with shell anchors.
Final Answer:
pat$
mail
program's internal command set, which command forwards the current message to the specified user-list?
Discussion & Comments