Tips Linux / FreeBSD

การค้นหาไฟล์ใน Linux ด้วยคำสั่ง find

find / -name test01.txt [enter] < ค้นหาไฟล์ test01.txt จากรากไดเร็กทอรี

find /etc -name passwd [enter] < ค้นหาไฟล์ passwd จากไดเร็กทอรี /etc

find /etc -name php.ini [enter] < ค้นหาไฟล์ php.ini จากไดเร็กทอรี /etc/

find /etc/httpd -name httpd.conf [enter] < ค้นหาไฟล์ httpd.conf จากไดเร็กทอรี /etc/httpd

find /var/www/html -name *.pdf [enter] < ค้นหาไฟล์ *.pdf จากไดเร็กทอรี /var/www/html

การค้นหาคำหรือข้อความในไฟล์
grep cmsconnect ในไฟล์ configuration.php [enter] < ค้นหาคำว่า cmsconnect ในไฟล์ configuration.php

grep det ในไฟล์ test01.txt [enter] < ค้นหาคำว่า sdet ในไฟล์ test01.txt

grep “This is a Edicational Technology” /data/test01.txt [enter] < ค้นหาข้อความภายในเครื่องหมาย ” ”

การนับบรรทัดในไฟล์
wc test01.txt [enter] < นับบรรทัดในไฟล์ test1.txt

wc /etc/passwd [enter] < นับบรรทัดในไฟล์ passwd