我想用以下內容更改檔案:
[Peer]
PublicKey = gpS4RheuHn /RIyT H2Eur3nPxOKxSLDXPtyt1vqFAg=
AllowedIPs = 10.0.0.2/32
[Peer]
PublicKey = 8j/QYgGxeqMNRrKe5V/yQpBf8k8gX63bDBmeuKWhDTY=
AllowedIPs = 10.0.0.3/32
[Peer]
PublicKey = 6lcI cBb79SS1v60kG63QPvoHvegP1ESqOjeZReUBwo=
AllowedIPs = 10.0.0.4/32
[Peer]
PublicKey = UqMYp8SbLvdnRpWG9t3Ve9SMKvmASnWE0w0XIe9XGQc=
AllowedIPs = 10.0.0.5/32
[Peer]
PublicKey = S7bbWxHECZfbnzJrDGcQOvGHq4/E7rAn4LAemtrDnRs=
AllowedIPs = 10.0.0.6/32
[Peer]
PublicKey = rSu3IGLcSZTiWTPyBRC0U12N5Ho6TMIHVfXu2An7Fyo=
AllowedIPs = 10.0.0.7/32
至
# Peer: 1
[Peer]
PublicKey = gpS4RheuHn /RIyT H2Eur3nPxOKxSLDXPtyt1vqFAg=
AllowedIPs = 10.0.0.2/32
# Peer: 2
[Peer]
PublicKey = 8j/QYgGxeqMNRrKe5V/yQpBf8k8gX63bDBmeuKWhDTY=
AllowedIPs = 10.0.0.3/32
# Peer: 3
[Peer]
PublicKey = 6lcI cBb79SS1v60kG63QPvoHvegP1ESqOjeZReUBwo=
AllowedIPs = 10.0.0.4/32
# Peer: 4
[Peer]
PublicKey = UqMYp8SbLvdnRpWG9t3Ve9SMKvmASnWE0w0XIe9XGQc=
AllowedIPs = 10.0.0.5/32
# Peer: 5
[Peer]
PublicKey = S7bbWxHECZfbnzJrDGcQOvGHq4/E7rAn4LAemtrDnRs=
AllowedIPs = 10.0.0.6/32
# Peer: 6
[Peer]
PublicKey = rSu3IGLcSZTiWTPyBRC0U12N5Ho6TMIHVfXu2An7Fyo=
AllowedIPs = 10.0.0.7/32
我試過:
awk '/[Peer]/{print "# Peer: " c} 1'
但不起作用。許多雙輸出。
我想# Peer: sequence number在每場比賽之前插入一個單詞。
我嘗試使用 awk,它給了我許多雙重輸出。
uj5u.com熱心網友回復:
嘗試使用 awk '/[Peer]/{print "# Peer: " c}1' 但不起作用。許多雙輸出。
您忘記了轉義[and ],/[Peer]/表示任何包含Pore或eor的行r,添加\轉義序列
/\[Peer\]/{print "# Peer: " c}1
并且您的代碼應該按預期作業,但請記住[Peer],如果您希望限制[Peer]跨越整行,這將檢查行是否包含任何地方
$0=="[Peer]"{print "# Peer: " c}1
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/532843.html
標籤:重击awksed
