Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error : unexpected EOF while looking for matching `''

I have created a script to export CSV data to mysql table.

#!/bin/bash

cd /data/NEW

for f in User*
do
        mysql --user="root" --password="user@123" -e "LOAD DATA LOCAL INFILE  '/data/NEW/"$f"' ignore into table new.table2 fields terminated by ',' enclosed by '"' lines terminated by '\n' (table_date, table_name, table_count);"

done

But I am getting following errors. But I could not find where I have messed this.

test.sh: line 6: unexpected EOF while looking for matching `''
test.sh: line 9: syntax error: unexpected end of file

Can someone show me where to improve?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try escaping double quotes as follows:

#!/bin/bash

cd /data/NEW
for f in User*
do
        mysql --user="root" --password="user@123" -e "LOAD DATA LOCAL INFILE  '/data/NEW/$f' ignore into table new.table2 fields terminated by ',' enclosed by '\"' lines terminated by '\n' (table_date, table_name, table_count);"

done
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading