-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmenu.sh
48 lines (40 loc) · 893 Bytes
/
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
48
#!/bin/bash
if_function() {
#list all of the interfaces and print the IPv4 for each one that is up
iflist=$(ifconfig -l)
for iface in $iflist
do
ipcheck=$(ifconfig $iface | grep "inet " | cut -d" " -f2)
if [ -n "$ipcheck" ]
then
echo "The interface is called: $iface and it's IP is:"
echo $ipcheck
fi
done
}
while [ true ]
do
#Print out menu choices
echo "What command would you like to run?"
echo ""
echo "1) ifconfig"
echo "2) df -h"
echo "3) exit"
echo ""
#get users choice
read -p '[1-3]: ' choice
#depending on user's choice, run the command
case "$choice" in
1)
if_function
;;
2)
df -h
;;
3)
break
;;
esac
done
echo "We are done! Good Bye!"
exit 0