Many times, we may not pass arguments to the command line, but we may need to set parameters internally inside the script.
We can declare parameters with the set command, as follows:
$ set USA Canada UK France$ echo $1USA$ echo $2Canada$ echo $3UK$ echo $4France
We can use this inside the set_01.sh script, as follows:
#!/bin/bash set USA Canada UK France echo $1 echo $2 echo $3 echo $4
Run the script as this:
$ ./set.sh
The output is as follows:
USACanadaUKFrance
Following is a summary of the declare options:
Option |
Meaning |
-a |
An array is created |
-f |
Displays the function names and definitions |
-F |
Displays only the function names |
-i |
Makes the variables integer types |
-r |
Makes the variables ... |