-
Notifications
You must be signed in to change notification settings - Fork 0
/
colo1.sh
executable file
·61 lines (51 loc) · 1.12 KB
/
colo1.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
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#Author: Poorvak Kapoor
#Assigning color to the screens
BG_BLUE="$(tput setab 4)"
BG_BLACK="$(tput setab 0)"
FG_GREEN="$(tput setaf 2)"
FG_WHITE="$(tput setaf 7)"
#Save screen
tput smcup
#display menu until selection == 0
while [[ $REPLY != 0 ]]; do
echo -n ${BG_BLUE}${FG_WHITE}
clear
cat <<- _EOF_
Please Select:
1. Display Hostname and Uptime
2. Display Disk Space
3. Display Home Space Utilization
0. Quit
_EOF_
read -p "Enter select [0-4]" selection
#Clear area beneath menu
tput cup 10 0
echo -n ${BG_BLACK}${FG_GREEN}
tput ed
tput cup 11 0
case $selection in
1) echo "Hostname: $HOSTNAME"
uptime
;;
2) df -h
;;
3) if [[ $(id -u) -eq 0 ]]; then
echo "Home space utilization (All users)"
du -sh /home/* 2> /dev/null
else
echo "Home Space utilization ($USER)"
du -s $HOME/* 2> /dev/null | sort -nr
fi
;;
0) break
;;
*) echo "Invalid entry"
;;
esac
printf "\n\nPress any key to continue"
read -n 1
done
#Restore screen
tput rmcup
echo "Program terminated"