When writing a script in bash you can pass parameters into that script to work with. For example, let’s say I have a script file called
runme.sh and I want to pass in my name and today’s date. I could do that like this.
./runme.sh "Adron Hall" "12/27/2018"
Inside the script I can get access to the parameters by using the bash param variables of $1, $2, and so on. With a little bash code written up like this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|echo "The first parameter $1"|
|echo "The second parameter is $2"|
|echo "The \$0 parametere returns the name of the file! This file is named $0."|