Re: "echo"ing a psql command in a bash script
От | Jim Wilson |
---|---|
Тема | Re: "echo"ing a psql command in a bash script |
Дата | |
Msg-id | twig.1094222345.61185@kelcomaine.com обсуждение исходный текст |
Ответ на | "echo"ing a psql command in a bash script (Ennio-Sr <nasr.laili@tin.it>) |
Ответы |
Re: "echo"ing a psql command in a bash script
|
Список | pgsql-general |
Ennio-Sr said: > (once for all): > cmnd=echo psql mydb -x -c "SELECT * FROM tb_nm WHERE $col_nm LIKE '%$k_r%'" That will be executed immediately, and give you an error. > (in each <case n>): > col_nm="....." > echo $cmnd I'm surprised you get anything. AFAIK this should parse the files in your directory into column names. Maybe you are doing something slightly different? Rather than setting the $cmnd variable, try using something like this: echo mydb -x -c \"SELECT "*" FROM tb_nm WHERE $col_nm LIKE \'%$k_r%\'\" | xargs psql I'm not sure where you are storing your column names, but if you can pipe it as a list into the above you won't need to rum a loop in your script. There are a thousand ways to do this, but most important is remember to quote the "*" so the shell doesn't parse it. BTW You did not say, so I'm also assuming you are using "bash" or "sh" since that's what this looks like. :-) Best, Jim
В списке pgsql-general по дате отправления: