-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.sh
More file actions
34 lines (30 loc) · 731 Bytes
/
Copy pathmenu.sh
File metadata and controls
34 lines (30 loc) · 731 Bytes
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
#!/bin/bash
while true; do
echo "Menu:"
echo "1. Create a file"
echo "2. View a file"
echo "3. Exit"
read -p "Enter your choice: " n
case $n in
1)
read -p "Enter file name: " file
touch "${file}.txt"
echo "File ${file}.txt created."
;;
2)
read -p "Enter file name: " file
if [[ -f "${file}.txt" ]]; then
cat "${file}.txt"
else
echo "File ${file}.txt does not exist."
fi
;;
3)
echo "Exiting..."
break
;;
*)
echo "Invalid choice. Please enter 1, 2, or 3."
;;
esac
done