-
Notifications
You must be signed in to change notification settings - Fork 0
/
while_menu.sh
executable file
·47 lines (37 loc) · 926 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
41
42
43
44
45
46
47
#!/bin/bash
# A menu driven system information program
# number of seconds to display results
DELAY=2
while [[ $REPLY != 0 ]]; 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] > "
if [[ $REPLY =~ [0-3] ]]; then
if [[ $REPLY == 1 ]]; then
echo "Hostname: $HOSTNAME"
uptime
sleep $DELAY
fi
if [[ $REPLY == 2 ]]; then
df -h
sleep $DELAY
fi
if [[ $REPLY == 3 ]]; then
if [[ $(id -u) -eq 0 ]]; then
echo "Home space utilization (all users)"
du -sh /Users/*
else
echo "Home space utilization ($USER)"
du -sh $HOME
fi
sleep $DELAY
fi
fi
done
echo "Program terminated"