Escaping single quotes in shell for postgresql

前端 未结 2 1902
青春惊慌失措
青春惊慌失措 2021-01-22 17:41

I\'m trying to execute SQK through psql under postgres account. I\'m able run SQL that doesn\'t contain quotes

root@server:/home/rosta/SCRIPTS# su postgres -c &qu         


        
2条回答
  •  故里飘歌
    2021-01-22 18:37

    Simplest way is to use a 'here document' , which ignores all quoting:

    #!/bin/sh
    DB_NAME=my_data_base
    
    psql -U postgres postgres <

提交回复
热议问题