2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 2320
/ 2 Years ago, fri, december 17, 2021, 2:51:50
I would like to do the following in a bash script:
- read some filenames out of an file with filenames
- set a variable input path
- concat 1. and 2.
- use 3. in sql-statement
Here my code:
#!/bin/bash
INPath="/home/bono/RD/BV-OUT/"
while
read line
do
RD="$line"
RDFile="$INPath$RD"
echo -e $RDFile
###MYSQLs:
mysql -u root -D RD --local-infile << EOF
LOAD DATA LOCAL INFILE '$RDFile'
INTO TABLE bv_tmp_all FIELDS TERMINATED BY ';' LINES TERMINATED BY '
';
EOF
##### EOSQL
done < /home/bono/RD/BV-OUT/allto468
The echo shows the right path and filenamen but mysql always says:
not found (Errcode: 2 - File or Directory not found)
I've tried different ways to concate the two strings but none worked :(
The following code works with mysql (without the concate) but it is not what I need:
#!/bin/bash
while
read line
do
RDFile="/home/bono/RD/BV-OUT/468-R11"
echo -e $RDFile
###MYSQLs:
mysql -u root -D RD --local-infile << EOF
LOAD DATA LOCAL INFILE '$RDFile'
INTO TABLE bv_tmp_all FIELDS TERMINATED BY ';' LINES TERMINATED BY '
';
EOF
##### EOSQL
done < /home/bono/RD/BV-OUT/allto468
What is wrong with the concate?
More From » command-line