gpt4 book ai didi

linux - Linux 中的特殊符号

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:25:46 24 4
gpt4 key购买 nike

$1 的用途是什么?在执行 java 文件时,我们将把它作为命令行参数。它指的是什么?

最佳答案

您在这里提供了一些上下文,但我认为这是 shell 参数。

ARGUMENTS

If arguments remain after option processing, and neither the -c nor the -s option has been supplied, the first argument is assumed to be the name of a file containing shell commands. If bash is invoked in this fashion, $0 is set to the name of the file, and the positional parameters are set to the remaining arguments. Bash reads and executes commands from this file, then exits. Bash's exit status is the exit status of the last command executed in the script. If no commands are executed, the exit status is 0. An attempt is first made to open the file in the current directory, and, if no file is found, then the shell searches the directories in PATH for the script.

有关更多详细信息,请尝试 man bash

示例

$ cat ./test.sh 
#!/bin/bash
echo $0
echo $@
$ ./test.sh hello world
./test.sh
hello world

关于linux - Linux 中的特殊符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13117682/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com