如何在一个命令行中读取输出文件?

Mos*_*ail 2 command-line firefox

如何正确地做这样的事情?

$: lshw -html > /tmp/specs.html < firefox
Run Code Online (Sandbox Code Playgroud)

也试过

$: firefox < "lshw -html > /tmp/specs.html"
Run Code Online (Sandbox Code Playgroud)

Leo*_*Mew 6

您应该将 lshw 输出到一个文件,然后使用 Firefox 打开该文件,如下所示:

lshw -html >/tmp/specs.html && firefox /tmp/specs.html
Run Code Online (Sandbox Code Playgroud)

或者

sudo lshw -html >/tmp/specs.html && firefox /tmp/specs.html
Run Code Online (Sandbox Code Playgroud)

更新:以下不使用临时文件,但需要 bcat
安装 bcat 包:

sudo apt install ruby-bcat
Run Code Online (Sandbox Code Playgroud)

那么你想要的命令很简单

lshw -html|bcat -b firefox
Run Code Online (Sandbox Code Playgroud)

bcat 帮助输出:

管道到浏览器实用程序。读取标准输入,可能是一个或多个,并将连接/格式化的输出写入浏览器。