jer*_*ile 6 bash gnu homebrew macos
我有一台Mac。我想使用CentOS 附带的GNU ,因为它比 BSD Mac 版本功能更全。具体来说,在 CentOS 机器上给出:script
man script
Run Code Online (Sandbox Code Playgroud)-c, --command command Run the command rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty.
而我的Mac上的版本没有这样的选项。我想在假装是 tty 的同时查看命令的输出,这是我知道如何做到这一点的唯一方法。
我有brew,并且安装了一堆GNU版本的实用程序(grep findutils coreutils gawk gnu-sed gnu-tar gnu-indent gnu-getopt gnutls
),但这些似乎都不提供script
.
我尝试搜索 Homebrew 公式,但不出所料,很多软件包都提到了“脚本”一词,所以我很容易错过它。
编辑:根据评论,我不确定是否有GNU script
,但肯定还有另一个版本,我的 Mac 没有。script --version
在 CentOS 7 上返回 2.xx,在 Mac 上返回“非法参数”。
另外从评论来看,它听起来像util-linux
provided script
,但是brew版本没有script
我可以找到的命令:
-c, --command command
Run the command rather than an interactive shell. This makes it easy for a script to
capture the output of a program that behaves differently when its stdout is not a tty.
Run Code Online (Sandbox Code Playgroud)
小智 1
如果您的目标是欺骗命令认为 stdout 是 TTY,您可以改用unbuffer
。它是expect
酿造配方的一部分。
brew install expect
unbuffer -p <COMMAND_TO_TRICK>
Run Code Online (Sandbox Code Playgroud)
例子:
echo "colorme" | unbuffer -p grep --color=auto colorme | cat
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
729 次 |
最近记录: |