Author Topic: ต้องการ grep หาคำ และทำการ sed ให้เป็น คำใหม่  (Read 1024 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
#วันนี้มีโจทย์ grep เจอชื่อไฟล์ ทั้งหมดที่เจอคำว่า http และให้เปลี่ยนเป็นคำว่า https ภายใต้ folder "domain"
grep -rl "http://abc" *.php | xargs sed -i 's/http/https/g'

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

 8)