xdg-open URL 来自文本文件

xdg-open URL from text file

我有一个 python 脚本,它每 x 分钟将 url 写入一个 txt 文件。

我希望通过 xdg-open 在浏览器中打开此 url。

xdg-open /home/user/test.txt (opens the txt file)
xdg-open https://example.url (opens the url)

我尝试将 cat 命令与 xdg-open 结合使用,但没有成功。

有没有什么方法可以在没有辅助脚本的情况下完成这项工作?

你可以试试 xargs:

url.txt:

https://google.com
https://github.com

命令:

< ~/url.txt xargs -I % xdg-open %