我有一个像这样的批处理文件:
java temptable %1 %2
我需要上述内容的等效shell脚本。我将把参数传递给shell脚本,然后应该将它们传递给temptable。
我有一个像这样的批处理文件:
java temptable %1 %2
对于bash(它是一种shell,但可能是Linux世界中最常见的),等效的命令是:
对于bash(它是一种 shell,但可能是Linux世界中最常见的),等效的命令是:
java temptable $1 $2
假设参数中没有空格。如果存在空格,您应该对参数加引号:
java temptable "$1" "$2"
你也可以这样做:
java temptable $*
或者:java temptable "$@"
如果你想要传递所有参数(注意,第二个参数等同于引用每个参数:"$1" "$2" "$3" ...)。
#!/bin/bash
# Call this script with at least 3 parameters, for example
# sh scriptname 1 2 3
echo "first parameter is $1"
echo "Second parameter is $2"
echo "Third parameter is $3"
exit 0
输出:
[root@localhost ~]# sh parameters.sh 47 9 34
first parameter is 47
Second parameter is 9
Third parameter is 34