我已经解析了文本文件中包含 url 和附加换行符的所有行,并且我想让链接在新文件中可单击。
如何<a href>
使用标准 Linux 工具(最好是 awk)仅在 url 周围附加 -tags?它需要在 cron 中实现自动化。
例如,
源文件chaturls.txt:
12:30 <user> check this: https://link.to/stuff.jpg</br>
13:47 <user4> https://another.link.lol eyyyy</br>
Run Code Online (Sandbox Code Playgroud)
新文件chatlinkified.html中的所需输出:
12:30 <user> check this: <a href='https://link.to/stuff.jpg'>https://link.to/stuff.jpg</a></br>
13:47 <user4> <a href='https://another.link.lol'>https://another.link.lol</a> eyyyy</br>
Run Code Online (Sandbox Code Playgroud)
我尝试过awk '{printf "<a href=\"%s\">%s</a><br>", $0,$0}' chaturls.txt > chatlinkified.html
,但这使得整行成为(无效)可点击链接。