forked from ruanyf/simple-bash-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
while-menu.sh
executable file
·40 lines (40 loc) · 928 Bytes
/
while-menu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# while-menu: a menu driven system information program
DELAY=1 # Number of seconds to display results
while true; do
clear
cat << EOF
Please Select:
1. Display System Information
2. Display Disk Space
3. Display Home Space Utilization
0. Quit
EOF
read -p "Enter selection [0-3] > "
case "$REPLY" in
0)
break
;;
1)
echo "Hostname: $HOSTNAME"
uptime
;;
2)
df -h
;;
3)
if [[ $(id -u) -eq 0 ]]; then
echo "Home Space Utilization (All Users)"
du -sh /home/*
else
echo "Home Space Utilization ($USER)"
du -sh $HOME
fi
;;
*)
echo "Invalid entry."
;;
esac
sleep "$DELAY"
done
echo "Program terminated."