Finding files with find
หน้านี้ต้องใช้เบราว์เซอร์ล่าสุด (รองรับ SharedArrayBuffer) กรุณาอัปเดต Chrome, Edge, Firefox หรือ Safari เป็นเวอร์ชันล่าสุด
English
Searching the whole tree
lsshows one folder.findsearches a folder and everything inside it, however deep:
find .
.means "start in the current folder".findlists every file and folder it can reach.
English
Find by name
- Usually you want files matching a pattern. Use
-name:
find . -name "*.txt"
- This finds every
.txtfile in the tree — even ones buried three folders down. - Quote the pattern (
"*.txt") so the shell passes it tofinduntouched.

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.
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 walks the tree
find searches the whole tree below a directory.
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Find every .txt file, even deep inside subfolders, with find . -name "*.txt". (. means "start from here".)
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
You can also start the search from a subfolder. Find just the .txt files inside docs (and below) with find docs -name "*.txt".
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
find matches folder names too. Find where the folder called sub is, starting from here: find . -name sub.