Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何从BASH输入中获取星号值_Linux_Bash_Terminal_Sh - Fatal编程技术网

Linux 如何从BASH输入中获取星号值

Linux 如何从BASH输入中获取星号值,linux,bash,terminal,sh,Linux,Bash,Terminal,Sh,以下是来自命令行的输入: bash script.sh "input*" ";" "21" "yyyy-MM-dd" 在我当前的目录中,我有两个输入文件: input1.txt input2.txt 虽然我想从input'$1'中获取值'input*',但我得到了'input1.txt input2.txt'作为输入 有没有办法从'$1'获取值'input*'?您可以使用“$1”,其中1是第一个输入参数的编号 #!/bin/bash echo "$1" 但是您必须像这样传递input*

以下是来自命令行的输入:

bash script.sh "input*" ";" "21" "yyyy-MM-dd"
在我当前的目录中,我有两个输入文件:

  • input1.txt
  • input2.txt
虽然我想从input'$1'中获取值'input*',但我得到了'input1.txt input2.txt'作为输入

有没有办法从'$1'获取值'input*'

您可以使用
“$1”
,其中
1
是第一个输入参数的编号

#!/bin/bash

echo "$1"
但是您必须像这样传递
input*.txt

输出

[shell] ➤ ./test7.sh input\*.txt
input*.txt
问候


克劳迪奥

这里最重要的是引用,而不是括号。@tripleee,你是什么意思?你的回答好像括号很重要,但它们在这里是完全多余的。你是这样读的。。我没有写大括号是最重要的,然后引用…这就是你为什么投反对票的原因?