我正在编写一个基于菜单的 bash 脚本,其中一个菜单选项是发送带有文本文件附件的电子邮件。我在检查我的文件是否为文本文件时遇到问题。这是我所拥有的:
fileExists=10
until [ $fileExists -eq 9 ]
do
echo "Please enter the name of the file you want to attach: "
read attachment
isFile=$(file $attachment | cut -d\ -f2)
if [[ $isFile = "ASCII" ]]
then
fileExists=0
else
echo "$attachment is not a text file, please use a different file"
fi
done
Run Code Online (Sandbox Code Playgroud)
我不断收到错误消息:分隔符必须是单个字符。