[root@1-CentOS-7-30-LAMP ~]# cat selectmenu.sh
#!/bin/bashbash
###menu select######
###Dan Chen ########ide
######2019-6-5#######ui
執行結果:
[root@1-CentOS-7-30-LAMP ~]# sh selectmenu.sh
1) disk_patiton 3) memory_use 5) ip_connection
2) disk_use 4) cpu_use 6) quit
Please input your choice: 1ip
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00037e93input
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 6555647 3072000 82 Linux swap / Solaris
/dev/sda3 6555648 209715199 101579776 83 Linux
1) disk_patiton 3) memory_use 5) ip_connection
2) disk_use 4) cpu_use 6) quit
Please input your choice: 2
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 97G 5.5G 92G 6% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 17M 896M 2% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sr0 11G 11G 0 100% /mnt
/dev/sda1 197M 113M 84M 58% /boot
tmpfs 183M 0 183M 0% /run/user/0
1) disk_patiton 3) memory_use 5) ip_connection
2) disk_use 4) cpu_use 6) quit
Please input your choice: 3
total used free shared buff/cache available
Mem: 1823 366 180 16 1276 1199
Swap: 2999 0 2999
1) disk_patiton 3) memory_use 5) ip_connection
2) disk_use 4) cpu_use 6) quit
Please input your choice: 4
16:46:34 up 20 days, 22:19, 3 users, load average: 0.00, 0.01, 0.05
1) disk_patiton 3) memory_use 5) ip_connection
2) disk_use 4) cpu_use 6) quit
Please input your choice: 5
LISTEN 1
1) disk_patiton 3) memory_use 5) ip_connection
2) disk_use 4) cpu_use 6) quit
Please input your choice: 6it
總結:本例主要考察
1.Linux下菜單的編寫方法:上面是經過select+while循環+case選擇菜單編寫,還有一種方法是經過read+while循環編寫,有興趣的朋友能夠本身作一下
2.常見的系統管理命令:有不少這裏就不一一說明了,找到本身最喜歡的命令便可,這裏沒有作沒有命令的判斷有興趣的人能夠作一下。
3.命令結束後退出當前命令的使用io