Operation modes and symbols:
Operational Symbolic Meaning (*Common for Marking)
+, -addition, subtraction
*, /,%Multiplication, Division, Remaining
**Power operation
++, --self-increasing, self-decreasing
<,<=,>,>=Comparison Symbol
=, +=, -=, *=, /=,%=assignment
For example, a+=1 equals a=a+1
Common operation commands in SHELL:
Operational operations and meaning of operational commands
(). Operate with integers
let is used for integer operations, similar to ())
expr is used for integer calculation and has more functions
Calculator under BC Linux for integer and decimal operations
$[] User Integer Calculation
A simple demonstration of the operation command:
[root@localhost mnt]
[root@localhost mnt]
2
[root@localhost mnt]
[root@localhost mnt]
2
[root@localhost mnt]
[root@localhost mnt]
[root@localhost mnt]
2
[root@localhost mnt]
[root@localhost mnt]
1+1
[root@localhost mnt]
2
[root@localhost mnt]
> 1+2
> EOF
3
[root@localhost mnt]
2
[root@localhost mnt]
8
[root@localhost mnt]
6
Simple for statement:
[root@localhost mnt]
[root@localhost mnt]
[root@localhost mnt]
0
1
2
3
4
5
6
7
8
9
for statement implementation does not output 4 in 1..10:
[root@localhost mnt]
[root@localhost mnt]
1
2
3
5
6
7
8
9
10
[root@localhost mnt]
[root@localhost mnt]
1
2
3
5
6
7
8
9
10
Write a 10-second countdown script with operations and shell statements you've learned:
[root@localhost mnt]
[root@localhost mnt]
Write a script that counts down 1 minute to 10 seconds with operations and shell statements you have already learned:
(scripts display countdown with read interactive command)
[root@localhost mnt]
[root@localhost mnt]# sh countdown1.sh call
please input minute:2 Interactive input countdown of minutes and seconds to execute
please input second:10
Script:
Making a calculator from the above commands requires the following
Display after executing Calculator.sh
Please enter the number you want to operate on:
Enter the operation to operate on:
Enter the second number to operate on:
> Display values after execution <>
[root@localhost mnt]
[root@localhost mnt]
please input first int number: 1
please input calculator tactique: + Verify Addition
please input second int number: 1.2
2.2
[root@localhost mnt]
please input first int number: 2
please input calculator tactique: * Verify Multiplication
please input second int number: 3
6
[root@localhost mnt]
please input first int number: 6
please input calculator tactique: / Verify Division
please input second int number: 2.2
2
Database backup:
Execute db_dump.sh westos (database password)
After the script executes, all libraries in the database are backed up to the / mnt/mysqldump directory
in
The backup file name is Library Name.sql Error and ask for action when this file exists
do
Enter "S" to skip backup and backup "Library Name.sql" file when "B" is entered
For Library Name_backup.sql, overwrite source file when "O" is entered
Example of automatic service deployment:
Execute script lamp.sh
After the script executes, deploy the forums and set apache's network interface to 8080
Autologon script:
Execute auto_ssh.sh 172.25.254.100 westos
172.25.254.100 is ip
westos is the password
Automatically log on to 172.25.254.100 and stay logged on after executing the script
Batch script:
Detect all hosts open in the classroom and grab the check-in names and IPS of all hosts
Corresponding list, save the list in the / mnt/ip_host.list file