Reputation: 111
cat ./1.sh
#!/bin/bash
echo $1
set var1 = $1
echo var1 is $var1
kostas@elem:~/1$ argument1 var1 is
How to set var1 from first commandline argument?
Upvotes: 11
Views: 38065
Reputation: 531055
The correct assignment is simply the following, with no spaces on either side of the equal sign:
var1=$1
The command set var1 = $1
actually does the following:
$1
to "var1"$2
to "="$3
to the original first parameter $1
.Upvotes: 34