当前位置:网站首页>4、 Variable assignment method
4、 Variable assignment method
2022-06-24 01:40:00 【jackxiao】
- Definition a=1
- Parameter transfer
- cat test7.sh
#!/bin/bash a=$1 b=$2 echo "a-b=$(($a-$b))" echo "a+b=$(($a+$b))" echo "a*b=$(($a*$b))" echo "a/b=$(($a/$b))" echo "a**b=$(($a**$b))" echo "a%b=$(($a%$b))"
- read Read in -p Tips -t Waiting time for user input
read -t 30 -p " Please enter a number :" a
Please enter a number :11
Two 、read Enterprise case
Judge what you input , And carry out corresponding operations according to the entered serial number , The script is as follows
- cat select1.sh
#!/bin/bash
cat <<EOF
1.install lamp
2.install lnmp
3.exit
EOF
read -p " Please select a sequence number ( It has to be numbers ):" num
#1. Judge whether it is an integer
expr 2 + $num &>/dev/null
if [ $? -ne 0 ]
then
echo "Usage:$0 {1|2|3}"
exit 1
fi
#2. Judgment execution processing
if [ $num -eq 1 ]
then
echo "install lamp..."
elif [ $num -eq 2 ]
then
echo "install lnmp..."
elif [ $num -eq 3 ]
then
echo "bye."
exit
else
echo "Usage:$0 {1|2|3}"
exit 1
fi边栏推荐
- What is the website construction process? What details need to be valued?
- Echo framework: implementing distributed log tracing
- [technology for grass planting] lightweight 248 helps individual developers go to the cloud
- 什麼是養老理財?養老理財產品有哪些?
- [SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)
- How do users of Fortress computers add servers? How much does it cost to add servers for fortress users?
- Eight common errors in programming
- What is the website domain name trademark registration process? What is the use of a website domain name trademark?
- Dart series: metaworld pubspec Yaml file details
- "Ai+ education" and "Ai education": one for education and the other for Education
猜你喜欢

It's too difficult for me. Ali has had 7 rounds of interviews (5 years of experience and won the offer of P7 post)

【Flutter】如何使用Flutter包和插件
![[SQL injection 12] user agent injection foundation and Practice (based on burpsuite tool and sqli labs LESS18 target machine platform)](/img/c8/f6c2a62b8ab8fa88bd2b3d8f35f592.jpg)
[SQL injection 12] user agent injection foundation and Practice (based on burpsuite tool and sqli labs LESS18 target machine platform)

I, a 27 year old female programmer, feel that life is meaningless, not counting the accumulation fund deposit of 430000
![[SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)](/img/b5/a8c4bbaf868dd20b7dc9449d2a4378.jpg)
[SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)
![[flutter] comment utiliser les paquets et plug - ins flutter](/img/a6/e494dcdb2d3830b6d6c24d0ee05af2.png)
[flutter] comment utiliser les paquets et plug - ins flutter
随机推荐
什么是养老理财?养老理财产品有哪些?
Coding compass -- creating a software factory like a flowing cloud
Collation of commonly used glusterfs commands
What is hypervisor? What is the difference between type 1 and type 2?
EasyPlayer. JS play m3u8 error net:: err_ EMPTY_ Response, how to solve it?
What is the cost of domain name trademark registration? What is the use of domain names and trademarks?
Location and troubleshooting of memory leakage: analysis of heap profiling principle
What are the selected CDN content acceleration scenarios of Tencent cloud?
Analysis of the whole process of webapck5 core packaging principle
Implementation of asynchronous notification and event callback based on guava API
How to use IOT gateway to realize networking communication of smart road lamp posts
Activity Registration - Tencent cloud digital intelligence driven SME transformation and upgrading series salon · Zhuhai station
How to implement NSQ delay streaming technology in easycvr?
How to build a practical website and how to operate after the website goes online
Summary of various situations in which easycvr cannot use voice intercom function
Property management source code based on wechat applet
How to realize court face recognition / flow statistics based on easycvr technology?
Tke cluster setup linkerd2
DCOM horizontal movement of Intranet penetration
NJS triggers system command operation