Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use shell position variable

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 217

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report