WeCodeAcademy

Finding Text with grep

grep searches for text and prints only the lines that match. Use grep pattern file.

Examplebash
Open in editor »
/ $

>> appends a line instead of replacing the file. Notice grep apple skipped Apple pie: matching is case-sensitive. Add -i to ignore case, -n to show line numbers, -c to count matches, and -v to show lines that do not match.

Examplebash
Open in editor »
/ $
Quick check

Which command shows the matching lines of `log.txt` that contain "error", in any letter case?

Your turn: write the code

app.log is created for you. Print only the lines that contain ERROR.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.