I am trying to create a bash script that will populate my mysql table Players in a database called linus from a csv file called Players. The csv file has 10 columns named:
teams, ranking, games, wins, draws, losses, goalsFor, goalsAgainst, yellowCards, redCards
table has the same 10 columns with the same names. I am getting a strange syntax error referring to the last line in my script:
"syntax error near unexpected token `done'"
I cannot seem to see what the issue is with my code.
#!/bin/bash
input="Players.csv"
while IFS= read -r var
do
team='echo $var | cut ,'
ranking='echo $var | cut ,'
games='echo $var | cut ,'
wins='echo $var | cut ,'
draws='echo $var | cut ,'
losses='echo $var | cut ,'
goalsFor='echo $var | cut ,'
goalsAgainst='echo $var | cut ,'
yellowCards='echo $var | cut ,'
redCards='echo $var | cut ,'
mysql -h localhost -u linus --password= mypassword -D
linus -e \insert into Players "($team,$ranking,$games,$wins,$draws,$losses,$goalsFor,$goalsAgainst,$yellowCards,$redCards)"
done < "$input"