Ubuntu

如何在 Linux 上使用路徑中的空格導入 postgresql 文件?

  • June 4, 2015

如果我嘗試導入路徑中有空格的 sql 腳本,則找不到該文件。

mypsqluser=> \i /home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql
/home/markus/Documents/Projekte/My: No such file or directory

我試圖用反斜杠、雙反斜杠或引號來逃避它,但它也不起作用,請參閱:

mypsqluser=> \i /home/markus/Documents/Projekte/My\ App/Installation/server_sql_script.sql
/home/markus/Documents/Projekte/My: No such file or directory

mypsqluser=> \i "/home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql"
"/home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql": No such file or directory

它僅在路徑中沒有空格時才有效。但它與空間有什麼關係?

單引號就可以了;然後轉義空間是可選的: \i ‘/home/markus/Documents/Projekte/My\ App/Installation/server_sql_script.sql’

引用自:https://serverfault.com/questions/696538