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.Record Case (ดังนั้น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
- "มีบรรทัดข้อผิดพลาดกี่บรรทัด?" — กรองเพื่อเอาแต่ข้อผิดพลาด แล้วนับจำนวน它是一种 everyday combo
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เพื่อ.Record case- ให้ใส่เครื่องหมายอัญประกาศรอบ pattern ที่มีช่องว่างหรือตัวอักษรพิเศษ
Explore · สำรวจ
grep inside a pipeline · grep ภายใน pipeline
grep filters a stream — feed it the output of another command. · grep กรอง stream — ส่งเอาต์พุตของคำสั่งอื่นให้มัน
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. · มีข้อผิดพลาดกี่ข้อ? Pipe grep เข้า wc -l: grep error log.txt | wc -l