linux - 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 结合使用,但没有奏效。
有没有什么办法可以在没有辅助脚本的情况下完成这项工作?
解决方案
你可以试试xargs
:
网址.txt:
https://google.com
https://github.com
命令:
< ~/url.txt xargs -I % xdg-open %
推荐阅读
- json - Chrome - 将数据从网络保存到文件?
- javascript - 脚本适用于每篇文章,但不适用于最后一篇文章
- android - 我的 RecyclerView 不断重复相同的项目(Kotlin)
- windows - MongoDB:在 Windows 上安装 MongoDB 作为在 WAMP 上使用的服务不使用 conf 文件?
- python - python中是否存在while循环?
- android - 如何在没有通知的情况下启动后台服务?
- c# - 如何将文本文件中的一行存储到固定大小的数组中
- c - 在使用 lldb 调试 macOS 应用程序时,是否可以通过观察点观察寄存器的内容以进行更改?
- java - 用Java实现模型-视图-控制器的不同风格
- angular - Angular AsyncValidator 不能按我的意愿工作