cuốn sách gpt4 ai đã làm

linux - Sự khác biệt giữa $(command) và `command` trong tập lệnh

In lại Tác giả: Vũ trụ không gian 更新时间:2023-11-04 04:48:41 29 4
mua khóa gpt4 Nike

执行这样的命令有什么区别:

var=$(ls -alh /dir)

Làm điều này:

var=`ls -alh /dir`

一种方法是否能够比另一种方法在更多的解释器中使用?

câu trả lời hay nhất

它们都是命令替换

第 3.5.4 节 http://www.gnu.org/software/bash/manual/bashref.html

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by ‘$’, ‘`’, or ‘\’. The first backquote not preceded by a backslash terminates the command substitution. When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.

Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes.

If the substitution appears within double quotes, word splitting and filename expansion are not performed on the results.

关于linux - 脚本中 $(command) 和 `command` 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16735280/

29 4 0
không gian vũ trụ
Hồ sơ

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á taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress