psql 的 Shebang
我正在尝试编写 PostgreSQL 脚本,但 shebang 行出现问题,
#! /usr/bin/psql [ psql_args_here ] -f
select now();
这给了我错误,就好像我刚刚在命令行中没有任何参数的情况下输入了 psql
一样。我怎样做才正确?
I'm trying to write PostgreSQL script(s) but having a problem with shebang line
#! /usr/bin/psql [ psql_args_here ] -f
select now();
This gives me error as if I just entered psql
without any arguments in command line. How do I do it right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是 psql 不会跳过文件的第一行。
你可以尝试
或者简单地
The problem is that psql don't skip the first line of the file.
You could try
or simply
还有一个更好的解决方案。第一行应该是:
它作为常规的 shebang #!
http://rosettacode.org/wiki/Multiline_shebang#PostgreSQL
There is a even better solution. The first line should be:
It works as a regular shebang #!
http://rosettacode.org/wiki/Multiline_shebang#PostgreSQL