Golfreeze.packetlove.com: Life style of Golfreeze Canon400D Family kammtan.com Jazz Freebsd Unix Linux System Admin guitar Music

All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server => command , shell script ,tool , crontab => Topic started by: golfreeze on สิงหาคม 20, 2023, 12:32:48 PM

Title: ต้องการ grep หาคำ และทำการ sed ให้เป็น คำใหม่
Post by: golfreeze on สิงหาคม 20, 2023, 12:32:48 PM
#วันนี้มีโจทย์ grep เจอชื่อไฟล์ ทั้งหมดที่เจอคำว่า http และให้เปลี่ยนเป็นคำว่า https ภายใต้ folder "domain"
grep -rl "http://abc" *.php | xargs sed -i 's/http/https/g'

ถ้าเจอ1 file แก้ธรรมดาได้ แต่ถ้าเจอ 1000 file ก็ command ข้างบนได้เลยครับ ^_

 8)