小编dro*_*oso的帖子

为什么 ''cat "${1:-/dev/stdin} | ... &>/dev/null'' 在 bash 中工作而不在 dash 中工作?

脚本:

#!/bin/sh
#
# reads stdin/file and copies it to clipboard
# clears it after 30s
#
cat "${1:-/dev/stdin}" | timeout 30 xclip -i -selection clipboard -r -verbose &>/dev/null &
Run Code Online (Sandbox Code Playgroud)

我可以看到只有标准输入不起作用(使用 bash 它适用于标准输入/文件)。
PS verbose 用于使 xclip 不被守护进程。

shell bash pipe io-redirection dash

5
推荐指数
3
解决办法
2331
查看次数

标签 统计

bash ×1

dash ×1

io-redirection ×1

pipe ×1

shell ×1