Using grep to Search Text Patterns
📖 Scenario: You are working with a simple text file that contains a list of fruits and their colors. You want to find specific fruits by searching for text patterns inside this file.
🎯 Goal: Learn how to use the grep command to search for text patterns in a file and display matching lines.
📋 What You'll Learn
Create a text file named
fruits.txt with exact contentUse a variable to store the search pattern
Use
grep with the variable to find matching linesDisplay the matching lines as output
💡 Why This Matters
🌍 Real World
Searching text files for specific words or patterns is common when working with logs, configuration files, or data files.
💼 Career
Knowing how to use grep helps in troubleshooting, data analysis, and automating tasks in many IT and software roles.
Progress0 / 4 steps