Search Postgresql Archives

bash & postgres

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm trying to pass variables on a bash script embedded with psql commands.

cat header.txt

"to1","from1","subject1"
"to2","from2","subject2"
"to3","from3","subject3"
"to4","from4","subject4"

cat b.sh

#!/bin/bash
two="2"

psql -h localhost -U postgres -d mobile -c "create temp table header (

 field_1   text    not null,
 field_2   text    not null,
 field_3   text    not null

);

\\copy header FROM header.txt CSV

SELECT * FROM header limit "$two"; "


When I execute b.sh
================================
ERROR:  syntax error at or near "\"
LINE 10: \copy header FROM header.txt CSV
         ^

How do I use \c (or any other psql commands beginning with a "\") in a
bash script?

Thanks.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux