当前位置:网站首页>Variable declaration and some special variables in shell

Variable declaration and some special variables in shell

2022-06-24 08:36:00 Chen Bucheng I

There are several points to observe or pay attention to when declaring variables :

  • stay SHELL The variables defined in are more direct , No type difference .
  • There can be no spaces between variable names and equal signs .
  • The first character of a variable name must be a letter .
  • You can use underscores in variable names .
  • There can be no spaces in the variable name , Dollar symbol $, Punctuation .
  • Variable names cannot use keywords .

Now use mind map , More intuitive

$0: File name of the current script

$n: Parameters passed to a script or function .n It's a number , Indicates the number of parameters . for example , The first parameter is $1, The second parameter is $2.

$#: Number of arguments passed to script or function .

$*: All parameters passed to a script or function .

[email protected]: All parameters passed to a script or function . By double quotes (" ") Inclusion time , And $* not quite the same , I'll talk about .

$?: Exit status of last command , Or the return value of the function .

$$: At present Shell process ID. about Shell Script , It's the process of these scripts ID

原网站

版权声明
本文为[Chen Bucheng I]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/06/20210622172021236T.html