Error : unexpected EOF while looking for matching `''
Error : unexpected EOF while looking for matching `''
我创建了一个脚本来将 CSV 数据导出到 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
但我收到以下错误。但是我找不到我把它弄乱的地方。
test.sh: line 6: unexpected EOF while looking for matching `''
test.sh: line 9: syntax error: unexpected end of file
谁能告诉我哪里需要改进?
尝试转义双引号,如下所示:
#!/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
我创建了一个脚本来将 CSV 数据导出到 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
但我收到以下错误。但是我找不到我把它弄乱的地方。
test.sh: line 6: unexpected EOF while looking for matching `''
test.sh: line 9: syntax error: unexpected end of file
谁能告诉我哪里需要改进?
尝试转义双引号,如下所示:
#!/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