Skip to content

Commit a5ca9ce

Browse files
committed
add new scripts
1 parent 77f5709 commit a5ca9ce

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ A collection of simple Bash scripts.
66
1. [Process.sh](scripts/Process.sh): execute more than one command in a script
77
1. [Interactive.sh](scripts/Interactive.sh): a simple but very much interactive script
88
1. [Special_Pattern.sh](scripts/Special_Pattern.sh): draw a diamond pattern with dots(.)
9+
1. [While-Read.sh](scripts/while-read.sh): read lines from a file using while loop
910
1. [Read-Menu.sh](scripts/read-menu.sh): display a menu for system information
11+
1. [While-Menu.sh](scripts/while-menu.sh): a repeated menu for system information
1012
1. [Colorfull.sh](scripts/Colorfull.sh): provide you with the output of several colours
1113
1. [Convertlowercase.sh](scripts/convertlowercase.sh): convert data either from the file or standard input to lowercase
1214
1. [Encrypt.sh](scripts/Encrypt.sh): encrypt a file/folder with password

scripts/while-menu.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# while-menu: a menu driven system information program
3+
DELAY=1 # Number of seconds to display results
4+
while [[ $REPLY != 0 ]]; do
5+
clear
6+
cat <<_EOF_
7+
Please Select:
8+
1. Display System Information
9+
2. Display Disk Space
10+
3. Display Home Space Utilization
11+
0. Quit
12+
_EOF_
13+
read -p "Enter selection [0-3] > "
14+
if [[ $REPLY =~ ^[0-3]$ ]]; then
15+
if [[ $REPLY == 1 ]]; then
16+
echo "Hostname: $HOSTNAME"
17+
uptime
18+
sleep $DELAY
19+
fi
20+
if [[ $REPLY == 2 ]]; then
21+
df -h
22+
sleep $DELAY
23+
fi
24+
if [[ $REPLY == 3 ]]; then
25+
if [[ $(id -u) -eq 0 ]]; then
26+
echo "Home Space Utilization (All Users)"
27+
du -sh /home/*
28+
else
29+
echo "Home Space Utilization ($USER)"
30+
du -sh $HOME
31+
fi
32+
sleep $DELAY
33+
fi
34+
else
35+
echo "Invalid entry."
36+
sleep $DELAY
37+
fi
38+
done
39+
echo "Program terminated."

scripts/while-read.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# while-read: read lines from a file
3+
while read ; do
4+
printf "%s\n" $REPLY
5+
done < /etc/passwd

0 commit comments

Comments
 (0)