shell script pass arguments code example
Example 1: pass parameters to bash script
echo "argument1: $1"
echo "argument2: $2"
Example 2: shell script get arguments
$ myscript.sh first_arg second_arg
echo $1
echo $2
Example 3: run sh with parameter
> ./myscript myargument
myargument becomes $1 inside myscript.
Example 4: get additional parameters linux scripting
$ cat myscript
echo "First arg: $1"
echo "Second arg: $2"
$ ./myscript hello world
First arg: hello
Second arg: world
Example 5: bash pass all arguments
source script.sh "$@"