sách gpt4 ai đã đi

bash -x 命令

In lại 作者:行者123 更新时间:2023-11-29 08:43:31 25 4
mua khóa gpt4 Nike

我看到一个客户端执行 $bash -x 命令来查看文件是否可执行(或 ksh -x 命令等),就像 - x 在 shell 脚本的 nếu như 语句中。

我的问题是:$bash -x 命令有什么作用?

我的解释是在当前 shell 中的新 bash shell 中启动命令,继承相同的环境变量并由相同的用户执行。

有趣的是我可以执行 $ls 但不能执行 $bash -x ls,它给出:

(在 AIX 6 下)/usr/bin/ls:/usr/bin/ls: 无法执行二进制文件

错误的原因对我来说是个谜 - 猜测这是由于特权,这意味着我上面的假设是不正确的。

此外,我相信 $bash ls$bash -x ls 是同一件事(-x 表示“执行”)?

非常感谢任何评论。

干杯!

1 Câu trả lời

-x 选项以跟踪模式启动 BASH shell。您可以看到有关如何处理您的命令/脚本的所有详细信息。如果您的脚本没有按照您的预期执行,这是找到一些错误的好方法

而且,正如亚历克斯所说in a comment ,要在 BASH 中运行命令,您必须使用 -c 选项,例如 bash -x -c ls.

Xem thêm người đàn ông đập phá 或在线手册,特别是 invoking Bash 上的部分和 the bộ builtin command了解更多信息:

All of the single-character options used with the bộ builtin (see The Set Builtin) can be used as options when the shell is invoked.

-x

Print a trace of simple commands, commands, trường hợp commands, lựa chọn commands, and arithmetic commands and their arguments or associated word lists after they are expanded and before they are executed. The value of the PS4 variable is expanded and the resultant value is printed before the command and its expanded arguments.

关于bash -x 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10107124/

25 4 0
Bài viết được đề xuất: Bash、串行 I/O 和 Arduino
Bài viết được đề xuất: Java8 将来自流的随机点与来自其他流的播放器对象相关联
Bài viết được đề xuất: mysql - 使用Where子句更新
Bài viết được đề xuất: Java 流,从 ConcurrentLinkedQueue 中删除并执行操作
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com