I'm writing a script to parse a larger file into usable data. I will attach the script below. The script was not running as I wanted and I thought it might have been the if/then statement I used, but when I took that off it revealed the real problem. This is now the error I am getting which makes it seem like the real problem is a quote mark of some kind.
FirstName,LastName,Company,Address,City,County,State,ZIP,Phone,Fax,Email,Web
FinalProject.sh: 36: FinalProject.sh: Syntax error: Unterminated quoted string
While I technically understand what the syntax error means, I cannot find where the problem is, and I have been trying to fix it for about half an hour. Help would be greatly appreciated!
#!/bin/bash
OLDIFS=${IFS}
IFS=$'\n'
head -1 50000_a.csv | sed 's/"//g'
for LINE in 'grep WV 50000_a.csv | sed 's/"//g' | awk -F, '{print $(NF-11)"," \
$(NF-10)"," \
$(NF-9)"," \
$(NF-8)"," \
$(NF-7)"," \
$(NF-6)"," \
$(NF-5)"," \
$(NF-4)"," \
$(NF-3)"," \
$(NF-2)"," \
$(NF-1)"," \
$NF \
}''
do
FNAME='echo ${LINE} | awk -F, '{print $1}''
LNAME='echo ${LINE} | awk -F, '{print $2}''
COMPANY='echo ${LINE} | awk -F, '{print $3}''
ADDRESS='echo ${LINE} | awk -F, '{print $4}''
CITY='echo ${LINE} | awk -F, '{print $5}''
COUNTY='echo ${LINE} | awk -F, '{print $6}''
STATE='echo ${LINE} | awk -F, '{print $7}''
ZIP='echo ${LINE} | awk -F, '{print $8}''
PHONE='echo ${LINE} | awk -F, '{print $9}''
FAX='echo ${LINE} | awk -F, '{print $10}''
EMAIL='echo ${LINE} | awk -F, '{print $11}''
WEB='echo ${LINE} | awk -F, '{print $12}''
done