shell get arguments code example
Example 1: shell script get arguments
$ myscript.sh first_arg second_arg
echo $1
echo $2
Example 2: run sh with parameter
> ./myscript myargument
myargument becomes $1 inside myscript.
Example 3: 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 4: powershell get arguments
param (
[string]$server = "http://defaultserver",
[Parameter(Mandatory=$true)][string]$username,
[string]$password = $( Read-Host "Input password, please" )
)