Bash 基础知识系列 #2:在 Bash 中使用变量

888u

Last update at :2024-04-23,Edit by888u


Source: https://itsfoss.com/bash-use-variables/


Basics in Bash In the first part of the series, I briefly mentioned variables. Now it's time to learn about them in detail in this chapter.

If you have ever done any kind of coding, you are familiar with the term "variable".

If not, think of variables as boxes that hold information that can change over time.

Let's see how to use them.


Using variables in the Bash shell

Open a terminal and initialize the variable with a random number 4: < /p>

var=4

Now you have a variable named var with a value of 4. Want to verify? Access the value of a variable by prepending $ to the variable name. This is called parameter expansion.

 echo The value of var is $var
The value of var is 4

Bash 基础知识系列 #2:在 Bash 中使用变量

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码