I'm trying to execute a bash script and getting the "Unexpected EOF while looking for matching ' " ' error. Not sure where I'm messing up.
The script is designed to insert .md files as entries into a journal program. The journal program uses the following CLI code to insert each .md file: 'dayone2 -d="YYYY-MM-DD TT:TT" new < "filename". So the script extracts the date from the filename itself and runs the program as above.
#!/bin/bash
#
# October 11, 2015 - John Raymonds
#
for file in *.md
do
# do something on "$file"
year="$(echo "$file" | cut -c 13,14,15,16)"
day="$(echo "$file" | cut -c 18,19)"
month="$(echo "$file" | cut -c 21,22)"
theDate=\"$year"-"$month"-"$day" 12:00PM"\"
#The date should end up in this format "2017-01-24 12:00PM"
/usr/local/bin/dayone2 -d="$theDate" new < "$file"
rm "$file"
done
Where is the code wrong?