1、编写Shell脚本实现如下菜单界面 select Menu 1.exit 2.Edit file 3.Date 4.Calc
时间: 2024-05-05 17:20:29 浏览: 123
5.(vue3.x+vite)水平垂直居中实现方式.rar
Sure, I can help you with that. Here's a sample shell script that implements the menu interface for your requested options:
```bash
#!/bin/bash
while true; do
echo "===================="
echo "Menu:"
echo "1. Exit"
echo "2. Edit file"
echo "3. Date"
echo "4. Calculator"
echo "===================="
read -p "Please enter your choice: " choice
case $choice in
1)
echo "Exiting menu..."
exit
;;
2)
read -p "Please enter the file name to edit: " file
nano $file # You can replace this with your preferred text editor
;;
3)
date
;;
4)
read -p "Please enter a math expression to evaluate: " expr
echo "$expr = $(echo "scale=2;$expr" | bc)"
;;
*)
echo "Invalid choice! Please try again."
;;
esac
done
```
To run the script, save it to a file (e.g. menu.sh), make it executable (e.g. `chmod +x menu.sh`) and execute it (e.g. `./menu.sh`).
I hope that helps! Let me know if you have any other questions.
阅读全文