June 2017
Beginner
502 pages
11h 26m
English
Let's see now some variables which have some spacial uses that we can benefit from:
${1}, ${n}
The first interesting variables we want to explore have a special role in our scripts because they will let us capture more than an argument on our first command-line execution. Have a look at this bunch of lines:
!/bin/bash fistvariable=${1}secondvariable=${2}thirdvariable=${3} echo "The value of the first variable is ${1}, the second is ${2}, the third is ${3}"
Pay attention to $1, $2, $3:
zarrelli:~$ ./positional.sh The value of the first variable is , the second is , the third is
First try, no arguments on the command line, we see nothing printed for the variables:
zarrelli:~$ ./positional.sh 1 2 3The value of the first ...
Read now
Unlock full access