How to use shell position variable
This article mainly introduces how to use shell location variables, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
When we learn some frameworks, when we start this framework, we usually call a script and pass some parameters to the script, and the script will operate differently according to the parameters we pass. The parameters we pass are location variables.
So how does the script identify the parameters we pass?
Through $0 $1. To get this kind of command.
For example:. / test.sh a b
$0: script itself test.sh
1: the first parameter an of the script
$2: the second parameter b of the script
Write a script in which test.sh writes
Echo $0
Echo $1
Echo $2
Give test.sh, empower, execute test.sh ab, and view the execution result
In this way, you can get the user's instructions in the script to perform different operations.
Thank you for reading this article carefully. I hope the article "how to use shell location variables" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!