bash的-x命令 [英] bash -x command
问题描述
我看到一个客户做 $ bash的-x
命令查看该文件是可执行文件(或 KSH -x
命令等),如 -x
在shell脚本如果
语句。
I saw a client doing $bash -x
command to see if the file is executable (or ksh -x
command, etc.) like the -x
in the if
statement in the shell script.
我的问题是:这是什么 $ bash的-x
命令做
My question is: What does $bash -x
command do?
我的跨pretation是在当前shell中的一个新的bash shell来启动命令,继承同样的环境变量,由同一用户执行。
My interpretation was to start a command in a new bash shell within the current shell, inheriting the same environment variables and executed by the same user.
有趣的是,我所能做的 $ LS
而不是 $ bash的-x LS
,这给:
The funny thing is I can do $ls
but not $bash -x ls
, which give:
(AIX 6下)的/ usr / bin中/ LS:在/ usr / bin中/ LS:不能执行二进制文件
这对我来说是一个谜,为什么错误是 - 猜测这是由于特权,这意味着以上我的假设是不正确的。
It is a mystery for me why the error is - guessing it is due to a privilege which means my assumption above is not correct.
另外,我相信 $庆典LS
和 $ bash的-x LS
是同样的事情( -x
为执行)?
Also, I believe $bash ls
and $bash -x ls
is the same thing (-x
for "execute")?
任何意见都很大AP preciated。
Any comments are greatly appreciated.
干杯!
推荐答案
的 -x
选项启动在调试模式是bash shell。你可以看到你的命令/脚本是怎么处理的所有细节。这是找一些错误的好方法,如果你的脚本不能做你希望是什么
The -x
option starts a BASH shell in debug mode. You can see all the details of how your command/script is processed. It's a good way to find some bugs if your script does not do what you would expect to
而且,正如亚历克斯在上面的评论说。在BASH运行命令,你必须使用 -c
选项如的bash -x -c LS
。
And just as Alex said in the comment above. To run a command in BASH, you have to use -c
option like bash -x -c ls
.
请参阅男人庆典
(设置
内置命令),了解更多信息。
See man bash
(set
built-in command) for more information.
这篇关于bash的-x命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!