Searching with grep
تحتاج هذه الصفحة إلى متصفح حديث (يدعم SharedArrayBuffer). يرجى تحديث Chrome أو Edge أو Firefox أو Safari إلى أحدث إصدار.
English
Finding text with grep
grepsearches for a word and prints only the lines that contain it:
grep error log.txt
- Out of a huge log, you instantly see just the lines that matter.

English
Useful options
-iignores case (soErrormatcheserror).-nshows the line number of each match.-vinverts — show lines that do not match.
grep -n ok log.txt
English
grep loves pipes
grepshines at the end of a pipe, filtering another command's output:
cat log.txt | grep error | wc -l
- "How many error lines?" — filter to errors, then count them. An everyday combo.
English
Common mistakes
grep pattern filefinds matching lines; add-ito ignore case.- Quote a pattern that has spaces or special characters.
استكشف
grep inside a pipeline
grep filters a stream — feed it the output of another command.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Show only the lines of log.txt that contain error, using grep error log.txt.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
How many errors are there? Pipe grep إلى wc -l: grep error log.txt | wc -l.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Show every line of log.txt that does ليس contain error: the things that went well.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
On which lines of log.txt are the errors? Show each error خط with its line number in front.