当前位置:网站首页>Shell Scripting

Shell Scripting

2022-06-23 19:33:00 Jokic_ Rn

bash At the beginning of the instruction #!/bin/bash It means using the path /bin/ Under the bash perform shell command , Any one that appears later #! Are only considered as comments

Positional arguments

shell The script uses $*,[email protected],$#,$n To receive input parameters
[email protected] and $* All the input parameters ,[email protected] For treating these parameters separately , You can loop through each input parameter ,$* The input parameters are treated as a whole
$# Indicates the number of input parameters
$n Indicates the number of input parameters , such as $4 It means the first one 4 Input parameters ,${11} It means the first one 11 Input parameters .
Example :

#!/bin/bash

echo Total params numbers : $#
echo Second params is : $2
echo Params is : $*
for i in [email protected]
        do
                echo $i
        done

result

(base) [email protected]:~/.trash$ bash trash1.sh 123 love air hello_world okay
Total params numbers : 5
Second params is : love
Params is : 123 love air hello_world okay
123
love
air
hello_world
okay
原网站

版权声明
本文为[Jokic_ Rn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231729434186.html