首页 > 解决方案 > xdg-从文本文件打开 URL

问题描述

我有一个 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 结合使用,但没有奏效。

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

标签: linuxbashxdgutils

解决方案


你可以试试xargs

网址.txt:

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

命令:

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

推荐阅读