The process is:
- I have a list of files (that keeps growing)
- The NAMES of these files are written in a txt file (
filelist.txt
) - Each line of this txt will be a query to mysql return an output
- That output will be written on a txt file (
output_file.txt
)
ie, this is used to rename the files of 1. .
For example, the first line of txt file is "Yellow". Then it will search "Yellow" on mysql and return "Colour", which will be print on a txt.
My problem is on 3.. I'm using synology NAS. The bash code that I'm using to 3. isn't working:
#!/bin/sh
cat /volume1/blabla/filelist.txt | while read line
do
#check if file exists
if [ -f $line ]
then
#turn the file into a command
cmd=$(cat $line)
mysql -h xx.xxx.xx.xx -u xx -pxx --execute="SELECT xx FROM xx WHERE lastName LIKE '%cmd' " > /volume1/blabla/output_file.txt;
fi
done
I'm getting:
sh: -c: line 10: syntax error near unexpected token 'done'
sh: -c: line 10: 'done'