如何创建一个 shell 脚本来创建一个包含一大堆内容的文件。我目前有这个,但它似乎运行得不好。任何更清洁的方法也受到欢迎。
echo "Enter 1 to generate View"
echo "Enter 2 to generate Model and View"
echo "Enter 3 to generate View, Model and Template"
while true; do
read -p "Please select an option: " option
read -p "Please enter the name of the class you wold like to genrate: " class
case $option in
1 )
FILE="views/$class"
/bin/cat <<EOM >$FILE
some content
EOM
break;;
2 )
exit;;
3 )
exit;;
* )
echo "Enter 1 to generate View"
echo "Enter 2 to generate Model and View"
echo "Enter 3 to generate View, Model and Template";;
esac
done