Finding files with find · מציאת קבצים עם find
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
Searching the whole tree
lsshows one folder.findsearches a folder and everything inside it, however deep:
.means "start in the current folder".findlists every file and folder it can reach.
עברית
חיפוש בכל העץ
lsמראה תיקיה אחת.findמחפש בתיקיה ובכל מה שתוכנה בה, לא משנה כמה עמוק:
find .
.פירושו "התחל בתיקיה הנוכחית".findרשימת כל הקבצים והתיקיות שהוא יכול להגיע אליהם.
English
Find by name
- Usually you want files matching a pattern. Use
-name:
- This finds every
.txtfile in the tree — even ones buried three folders down. - Quote the pattern (
"*.txt") so the shell passes it tofinduntouched.
עברית
מציאת קובץ לפי שם
- בדרך כלל תרצה לקבצים המתאימים לדפוס. השתמש ב-
-name:
find . -name "*.txt"
- זה מחפש כל קובץ
.txtבעץ — גם אלו שקבורים שלושה תיקיות למטה. - סמן את הדפוס (
"*.txt") כדי שהמעביר יעביר אותו ל-findללא שינוי.
English
Why it is handy
- "Where did I put that file?" —
findanswers it in one line. - Combined with pipes, you can act on the results — for example count them with
wc -l.
עברית
למה זה נוח
- "איפה שמתי את הקובץ הזה?" —
findמשיב תשובה בשורה אחת. - בשילוב עם צינורות, ניתן לפעול על התוצאות — לדוגמה, לספור אותן באמצעות
wc -l.
English
Common mistakes
find . -name "*.txt"searches by name from the current folder down.- Quote the pattern so the shell does not expand it first.
עברית
טעויות נפוצות
find . -name "*.txt"מחפש לפי שם החל מהתיקיה הנוכחית ומטה.- הסגלו תבנית כדי שהשלל לא ירחיב אותה תחילה.
Explore · חקור
find walks the tree · find עובר על העץ
find searches the whole tree below a directory. · find מחפש בעץ כולו מתחת לתיקיה.
Find every .txt file, even deep inside subfolders, with find . -name "*.txt". (. means "start from here".) · מצא כל קובץ .txt, גם עמוק בתוך תיקיות משנה, עם find . -name "*.txt". (. פירושו "להתחיל מכאן".)
You can also start the search from a subfolder. Find just the .txt files inside docs (and below) with find docs -name "*.txt". · ניתן להתחיל את החיפוש גם מתוך תיקית משנה. מצא רק את הקבצים .txt בתוך docs (ומטה) עם find docs -name "*.txt".