从 xtrace 隐藏命令

jca*_*314 3 linux bash

有没有办法通过 xtrace on ( ) 来隐藏输出中的命令set -o xtrace

在 DOS 中,技术是在echo on隐藏命令前添加 符号@

tha*_*guy 5

我从未在 bash 中见过类似的技巧,但有时您可以使用子 shell 来临时启用对您感兴趣的命令的跟踪:

echo "This command is not traced"
(
  set -x
  echo "This command is traced"
)
echo "No longer traced"
Run Code Online (Sandbox Code Playgroud)

如果因为您想要修改环境而导致子 shell 不适合,您可以set -x然后set +x,但这会给您留下跟踪set +x命令的痕迹。