I am writing a menu based bash script, one of the menu options is to send an email with a text file attachment. I am having trouble with checking if my file is a text file. Here is what I have:
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
I keep getting the error cut: delimiter must be a single character.