Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 使用set-x并导出到文件_Bash_Bash4 - Fatal编程技术网

Bash 使用set-x并导出到文件

Bash 使用set-x并导出到文件,bash,bash4,Bash,Bash4,有没有办法将set-x的所有输出导出到一个文件中? 我的练习是使用set-x执行一些功能,如mkdir和touch 并将所有输出导出到一个文件 谢谢 $ (set -x; echo hello) &> foo.txt $ cat foo.txt + echo hello hello bash-x将内容输出到标准错误,这样您就可以运行一个子shell并将其stderr重定向到一个文件。@Roey您可以通过script-a session.log保存运行的所有内容--只需运行您登录

有没有办法将
set-x的所有输出导出到一个文件中?
我的练习是使用
set-x
执行一些功能,如
mkdir
touch
并将所有输出导出到一个文件

谢谢

$ (set -x; echo hello) &> foo.txt

$ cat foo.txt
+ echo hello
hello

bash-x
将内容输出到标准错误,这样您就可以运行一个子shell并将其stderr重定向到一个文件。@Roey您可以通过script-a session.log保存运行的所有内容--只需运行您登录的脚本并启动脚本/会话即可。它会将每个命令及其输出保存到指定的日志文件中