Difficulty: Easy
Correct Answer: grep sales empl.lst
Explanation:
Introduction / Context:
Searching text is a core Unix capability. grep scans files for patterns and prints lines that match. This forms the basis of countless data-processing pipelines, log reviews, and audit scripts. Recognizing correct grep usage is essential for effective command-line work.
Given Data / Assumptions:
Concept / Approach:
The basic grep syntax is grep pattern file. By default, grep prints each matching line to standard output. You can add options like -i for case-insensitive search, -n for line numbers, or -w to match whole words only, but none are required here.
Step-by-Step Solution:
Verification / Alternative check:
Run grep sales empl.lst and compare output against manual inspection with less or more. Line count can be confirmed with grep -c sales empl.lst to ensure completeness.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting to quote patterns containing shell metacharacters; using grep without -F when the pattern includes regex special characters that should be treated literally; writing results back into the same source file inadvertently.
Final Answer:
grep sales empl.lst
Discussion & Comments