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להתעלם מגודל האותיות.- הנח בסימני הציטוט דפוס that contains spaces or special characters.
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.