小智 8
从手册中:
Run Code Online (Sandbox Code Playgroud)-v Print shell input lines as they are read. -x Print commands and their arguments as they are executed.
当查看管道命令的处理方式时,您可以看到这种区别:
$ set -v
$ echo "Hello World" | sed 's/World/Earth/'
echo "Hello World" | sed 's/World/Earth/'
Hello Earth
Run Code Online (Sandbox Code Playgroud)
相对:
$ set -x
$ echo "Hello World" | sed 's/World/Earth/'
+ sed s/World/Earth/
+ echo 'Hello World'
Hello Earth
Run Code Online (Sandbox Code Playgroud)
此外,xtrace (-x) 似乎使用 $PS4 变量,而 verbose (-v) 则不使用。