Searching with grep · البحث باستخدام grep
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · تحتاج هذه الصفحة إلى متصفح حديث (يدعم SharedArrayBuffer). يرجى تحديث Chrome أو Edge أو Firefox أو Safari إلى أحدث إصدار.
English
Finding text with grep
grepsearches for a word and prints only the lines that contain it:
- Out of a huge log, you instantly see just the lines that matter.
العربية
البحث عن نص باستخدام grep
grepيبحث عن كلمة ويطبع فقط الأسطر التي تحتوي عليها:
grep error log.txt
- من بين سجل ضخم، ترى فوراً فقط الأسطر المهمة.
English
Useful options
-iignores case (soErrormatcheserror).-nshows the line number of each match.-vinverts — show lines that do not match.
العربية
خيارات مفيدة
-iيتجاهل حالة الأحرف (لذلكErrorيطابقerror).-nيعرض رقم السطر لكل تطابق.-vيعكس — يعرض الأسطر التي لا تطابق.
grep -n ok log.txt
English
grep loves pipes
grepshines at the end of a pipe, filtering another command's output:
- "How many error lines?" — filter to errors, then count them. A everyday combo.
العربية
grep يحب الأنابيب
grepيلمع في نهاية الأنبوب، حيث يفلتر مخرجات أمر آخر:
cat log.txt | grep error | wc -l
- "كم عدد أسطر الأخطاء؟" — فلتر للأخطاء، ثم عددها. مزيج يومي شائع.
English
Common mistakes
grep pattern filefinds matching lines; add-ito ignore case.- Quote a pattern that has spaces or special characters.
العربية
أخطاء شائعة
grep pattern fileيجد الأسطر المطابقة؛ أضف-iلتجاهل حالة الأحرف.- ضع نمطاً بين علامتي تنصيص إذا كان يحتوي على مسافات أو أحرف خاصة.
Explore · استكشف
grep inside a pipeline · grep داخل سلسلة الأنابيب
grep filters a stream — feed it the output of another command. · grep يرشح تدفقاً — قدّم له مخرجات أمر آخر.
Show only the lines of log.txt that contain error, using grep error log.txt. · اعرض فقط أسطر log.txt التي تحتوي على error، باستخدام grep error log.txt.
How many errors are there? Pipe grep into wc -l: grep error log.txt | wc -l. · كم عدد الأخطاء؟ أنبوب grep إلى wc -l: grep error log.txt | wc -l.