shell_工作中用到
菜单功能,执行显示
#!/bin/bash
#菜单选择功能,执行命令
while true #无限循环
do
clear
echo '-----------------------------'
echo '1.Display Cpu INFO:'
echo '2.Display system load:'
echo '3.Display Mem and swap INFO:'
echo '4.Display filesystem INFO:'
echo '5.exit program:'
echo '-------------------------------'
read -p 'please select an iterm(1-5):' u_select
case $u_select in 1)
echo $(cat /proc/cupinfo)
read -p 'pless enter to continue:'
;;
2)
echo $(uptime)
read -p 'pless enter to continue:'
;;
3)
echo $(free)
read -p 'pless enter to continue:'
;;
4)
echo $(df -h)
read -p 'pless enter to continue:'
;;
5)
exit
;;
*)
read -p 'pless selsct 1-5 ,pless enter to continue:'
esac
done
=================================
while 批量添加用户
#!/bin/bash
#批量添加用户
u=1
while [ $u -le 2 ]
do
useradd user$u
u=$((u+1))
done