I have this script:
echo -e ">> Please, insert edition folder name: ";
read editionfolder;
RSeditionfolder="$editionfolder";
sh -c $POSTGRESbin'psql -U '$POSTGRESuser' -h localhost -d '$POSTGRESdb' -c "select count(*) from d3_folders where folder_name = '\'$RSeditionfolder\'';"' > $queryFolder$tmpFile
For example, if I insert in editionfolder var: CD_199 FOTOS I receive an error:
FOTOS';": -c: line 0: unexpected EOF while looking for matching `"'
FOTOS';": -c: line 1: syntax error: unexpected end of file
$queryFolder has “query/” value and $tmpFile has “tmpfile”
But I don’t know what I’m doing wrong.
The result of this query is:
count
-------
0
(1 row)
I only want the number 0, in this case. I’m triying to put the result in a file and the next step is use sed in this file, I you know other way I would be very grateful to know it.
Thanks !!
The given command is a little messy, I would write that like
First of all, I would get rid of all those single quotes using $-variables inside the double quotes. Second, it would be good to clarify clause ’$queryFolder$tmpFile’ using explicit variable name borders,
${queryFolder}${tmpFile}. But in general the script is fine.