How do I pass arguments to shell script?
For bash (which is one shell, but probably the most common in the Linux world), the equivalent is:
java temptable $1 $2
assuming there's no spaces in the arguments. If there are spaces, you should quote your arguments:
java temptable "$1" "$2"
You can also do:
java temptable $*
or:
java temptable "$@"
if you want all parameters passed through (again, that second one is equivalent to quoting each of the parameters: "$1" "$2" "$3" ...).
#!/bin/bash# Call this script with at least 3 parameters, for example# sh scriptname 1 2 3echo "first parameter is $1"echo "Second parameter is $2"echo "Third parameter is $3"exit 0
Output:
[root@localhost ~]# sh parameters.sh 47 9 34first parameter is 47Second parameter is 9Third parameter is 34