linux - 在 Linux 的脚本环境中解密变量

标签 linux shell unix

Unix shell 脚本中的$@ 表示什么。例如:

A__JOB="$CLASS $@"

$CLASS 是我的 java 类文件名。那么

可能是什么意思
$@.

我做了什么? 我用 Google 搜索 :) 但 $@ 似乎是对 ir 的复杂查询,或者我可能不知道如何在谷歌中搜索特殊字符。

最佳答案

$@ 是传递的所有参数的值。

例如,如果您通过:

./script A B C D

那么 "$@"将等于 "A""B""C""D"

所以看起来目的是将传递给脚本的所有参数直接传递给java程序。

来自 bash 手册:

@ Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed).

关于linux - 在 Linux 的脚本环境中解密变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16536396/

相关文章:

shell - SWT - 可靠地知道 shell 用户是否切换到另一个 shell 的事件

shell - Unix shell 脚本 - 冒号的用途

macos - 为什么 MacOS 上的 unexpand 可以在没有 "-a"参数的情况下更改内部空间?

unix - 在unix中根据文件名时间戳查找目录中最旧的文件

java - 为参数化变量创建 shell 脚本

java - 使用 File.separator 的相对路径

python - 键盘同时输出到多个程序?

linux - linux中/etc/environment文件的标准内容

shell - 如何在Shell脚本中访问名称由各种字符串组成的变量?

linux - 在 bash 中使用从字符串解析的数组