开发者

Is there anything to convert HTML special characters in files to normal characters?

开发者 https://www.devze.com 2022-12-12 19:47 出处:网络
I have some source code files which came 开发者_运维问答to me by an HTML output, so they\'re pretty unusable.

I have some source code files which came 开发者_运维问答to me by an HTML output, so they're pretty unusable.

I have things like this:

%include "macros.mac"

Which should be:

%include "macros.mac"

Is there any script (sh, perl, batch, ...) to convert every file (there are about 200) to the appropriate characters? Characters include & lt;, & gt;, ... (I put an space in the middle so that it wont convert them to < and >.

Thank you, it's very appreciated.


If it is just about the four &"<> characters, sed(1) could help:

sed 's/&quot;/"/g; s/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g'

Update: My original proposal was the following and had a bug:

sed 's/&amp;/\&/g; s/&quot;/"/g; s/&lt;/</g; s/&gt;/>/g'

This would convert "&amp;gt;" into ">" which is wrong.


you can try a tool like windows grep or textcrawler for this

0

精彩评论

暂无评论...
验证码 换一张
取 消