将-x调试命令捕获到Bash中的文件中
发布时间:2020-12-15 19:03:38 所属栏目:安全 来源:网络整理
导读:在bash中使用set -x将shell扩展命令打印到stderr. 我想将它们重定向到文件或管道. 但不是整个输出 – 只有一些命令. 就像是: set -x command.txt ### -- command.txt param is made upecho $A $Bset +x 这会将调试输出发送到命令.文本. 可以这样做吗? 使用
在bash中使用set -x将shell扩展命令打印到stderr.
我想将它们重定向到文件或管道. 但不是整个输出 – 只有一些命令. 就像是: set -x command.txt ### <-- command.txt param is made up echo $A $B set +x 这会将调试输出发送到命令.文本. 可以这样做吗?
使用bash 4.1或更高版本:
#!/bin/bash exec 5> command.txt BASH_XTRACEFD="5" echo -n "hello " set -x echo -n world set +x echo "!" 输出到标准输出(FD 1): hello world! 输出到command.txt(FD 5): + echo -n world + set +x (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读