replace หลายจุด และหลาย pattern พร้อมกันจบในการรันคำสั่งครั้งเดียว

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น ภาษา Java ภาษา Python

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
jataz2
PHP Super Member
PHP Super Member
โพสต์: 275
ลงทะเบียนเมื่อ: 22/02/2011 11:48 am

replace หลายจุด และหลาย pattern พร้อมกันจบในการรันคำสั่งครั้งเดียว

โพสต์ที่ยังไม่ได้อ่าน โดย jataz2 »

replace หลายจุด และหลาย pattern พร้อมกันจบในการรันคำสั่งครั้งเดียว

ใช้คำสั่ง sed รันผ่านโปรเเกรม cygwin64 ติดตั้งใน window

sed.exe -i.bak 's/Directory/zzzzz/;s/Microsoft/bbbb/;s/(ADDS)/cccc/' D:/test2/example.txt

คำสั่งนี้หมายถึงง
s/Directory/zzzzz/ ถ้าเจอคำว่า Directory ในไฟล์ D:/test2/example.txt ให้ replace ทุกจุดที่พบด้วยคำว่า zzzzz
s/Microsoft/bbbb/ ถ้าเจอคำว่า Microsoft ในไฟล์ D:/test2/example.txt ให้ replace ทุกจุดที่พบด้วยคำว่า bbbb
s/(ADDS)/cccc/ ถ้าเจอคำว่า (ADDS) ในไฟล์ D:/test2/example.txt ให้ replace ทุกจุดที่พบด้วยคำว่า cccc
โดยจะเก็บไฟล์ original ก่อน replace ไว้ที่ D:/test2/example.bak ให้ด้วย

ถ้าต้องการดู option อื่นๆของคำสั่ง sed.exe ก็พิมพ์ sed.exe -h แล้วกด enter ครับ


ข้อความที่ถูก replace เสร็จแล้ว
Active zzzzz, like many information-technology efforts, originated out of a democratization of design using Request for Comments or RFCs. The Internet Engineering Task Force (IETF), which oversees the RFC process, has accepted numerous RFCs initiated by widespread participants. Active zzzzz incorporates decades of communication technologies into the overarching Active zzzzz concept then makes improvements upon them.cccccitation needed] For example, LDAP underpins Active Directory. Also X.500 directories and the Organizational Unit preceded the Active Directory concept that makes use of those methods. The LDAP concept began to emerge even before the founding of bbbb in April 1975, with RFCs as early as 1971. RFCs contributing to LDAP include RFC 1823 (on the LDAP API, August 1995),[6]RFC 2307, RFC 3062, and RFC 4533.[7][8][9]
bbbb previewed Active zzzzz in 1999, released it first with Windows 2000 Server edition, and revised it to extend functionality and improve administration in Windows Server 2003. Additional improvements came with subsequent versions of Windows Server. In Windows Server 2008, additional services were added to Active zzzzz, such as Active zzzzz Federation Services.cccc10] The part of the directory in charge of management of domains, which was previously a core part of the operating system,[10] was renamed Active Directory Domain Services cccc and became a server role like others.[3] "Active Directory" became the umbrella title of a broader range of directory-based services.[11] According to Bryon Hynes, everything related to identity was brought under Active Directory's banner

ข้อความ original
Active Directory, like many information-technology efforts, originated out of a democratization of design using Request for Comments or RFCs. The Internet Engineering Task Force (IETF), which oversees the RFC process, has accepted numerous RFCs initiated by widespread participants. Active Directory incorporates decades of communication technologies into the overarching Active Directory concept then makes improvements upon them.[citation needed] For example, LDAP underpins Active Directory. Also X.500 directories and the Organizational Unit preceded the Active Directory concept that makes use of those methods. The LDAP concept began to emerge even before the founding of Microsoft in April 1975, with RFCs as early as 1971. RFCs contributing to LDAP include RFC 1823 (on the LDAP API, August 1995),[6]RFC 2307, RFC 3062, and RFC 4533.[7][8][9]
Microsoft previewed Active Directory in 1999, released it first with Windows 2000 Server edition, and revised it to extend functionality and improve administration in Windows Server 2003. Additional improvements came with subsequent versions of Windows Server. In Windows Server 2008, additional services were added to Active Directory, such as Active Directory Federation Services.[10] The part of the directory in charge of management of domains, which was previously a core part of the operating system,[10] was renamed Active Directory Domain Services (ADDS) and became a server role like others.[3] "Active Directory" became the umbrella title of a broader range of directory-based services.[11] According to Bryon Hynes, everything related to identity was brought under Active Directory's banner
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: witsarutt000 และบุคลทั่วไป 41