簡體   English   中英

使用終端在文本文件中查找和替換。 如何逃脫所有角色?

[英]Find and replace in text file with terminal. How to escape all the characters?

我正在嘗試使用終端替換文件中的一些html代碼。

這是我正在使用的命令

perl -pi -w -e 's/find/replace/g;' /Volumes/Abc.html

我正在嘗試更換

<body> 

<body>
<div style="text-align: center;page-break-after:always;padding-top:0%;">
<img src="images/image-001.jpg" id="illustration" alt="illustration" />
<div id="caption" style="text-align:right;font-style:italic;"></div>
</div>

所以我一直在嘗試這個,但我無法弄清楚如何逃避所有角色。 你能幫我嗎?

perl -pi -w -e 's/<body>/<body>
<div style="text-align: center;page-break-after:always;padding-top:0%;">
<img src="images/image-001.jpg" id="illustration" alt="illustration" />
<div id="caption" style="text-align:right;font-style:italic;"></div>
</div>
/g;' /Volumes/Abc.html

謝謝!

使用其他分隔符,例如{}

perl -pi -w -e 's{<body>}{...}g' /Volumes/Abc.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM