pull variable from the command (bash) -


i'm trying write bash script can pull variables it's execution.

i cannot explain well, want variable same bash script.

let's in instance script wrote cmd.sh.

sh ./cmd.sh foobar       var = foobar 

and if possible, how can in script?

sh ./cmd.sh foo bar fubar       var1 = foo       var2 = bar       var3 = fubar 

how can create script bash.sh script can pull in variable above , use it

probably talking positional parameters.
cmd.sh:

#!/bin/bash var1="$1" var2="$2" var3="$3" echo "$var1 $var2 $var3" 

$1 first positional parameter i.e argument passed script.
$2 second positional parameter i.e argument passed script.
...and on...

now if run cmd.sh this:

./cmd.sh foo bar fubar 

the output be:

foo bar fubar 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -