Bash:在执行之前打印每个命令?
发布时间:2020-12-15 16:59:03 所属栏目:安全 来源:网络整理
导读:参见英文答案 In a shell script: echo shell commands as they are executed13个答案什么是最好的方法来设置一个bash脚本,打印每个命令之前执行它? 这将是伟大的调试目的。 我已经尝试这: CMD="./my-command --params stdout.txt 2stderr.txt"echo $CMD`
参见英文答案 >
In a shell script: echo shell commands as they are executed13个答案什么是最好的方法来设置一个bash脚本,打印每个命令之前执行它?
这将是伟大的调试目的。 我已经尝试这: CMD="./my-command --params >stdout.txt 2>stderr.txt" echo $CMD `$CMD` 它应该做的是先打印: ./my-command --params >stdout.txt 2>stderr.txt 然后执行./my-command –params,输出重定向到指定的文件。 set -o xtrace 要么 bash -x myscript.sh 这与标准/ bin / sh以及IIRC(它可能是一个POSIX的东西) 并记住,有bashdb(bash Shell Debugger,版本4.0-0.4) 要恢复正常,请退出子shell或 set +o xtrace (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |