将整个文件内容检索为字符串而不是逐字检索 - Linux 命令
Retrieve the entire file content as string instead of word by word - Linux command
我正在尝试在 npm 脚本中引用 .sql 文件。
package.json
"scripts": {
...,
"rls:on": "npm run typeorm query $(cat src/policies/enable-rls.sql)"
}
启用-rls.sql
ALTER TABLE folder ENABLE ROW LEVEL SECURITY;
在运行上面的命令中我得到以下错误:
QueryFailedError: unterminated quoted string at or near "ALTER"
因为 sql 从文件中读取检索为单个单词:
"ALTER" "TABLE" "folder" "ENABLE" "ROW" "LEVEL" "SECURITY;"
而不是全文:
"ALTER TABLE folder ENABLE ROW LEVEL SECURITY;"
读取 qsl 全文的命令是什么?
将 command substitution 部分,即 $(...)
,包含在 JSON 转义双引号 \"...\"
中
例如,将您的 npm 脚本更改为以下内容:
"scripts": {
...,
"rls:on": "npm run typeorm query \"$(cat src/policies/enable-rls.sql)\""
^^ ^^
}
我正在尝试在 npm 脚本中引用 .sql 文件。
package.json
"scripts": {
...,
"rls:on": "npm run typeorm query $(cat src/policies/enable-rls.sql)"
}
启用-rls.sql
ALTER TABLE folder ENABLE ROW LEVEL SECURITY;
在运行上面的命令中我得到以下错误:
QueryFailedError: unterminated quoted string at or near "ALTER"
因为 sql 从文件中读取检索为单个单词:
"ALTER" "TABLE" "folder" "ENABLE" "ROW" "LEVEL" "SECURITY;"
而不是全文:
"ALTER TABLE folder ENABLE ROW LEVEL SECURITY;"
读取 qsl 全文的命令是什么?
将 command substitution 部分,即 $(...)
,包含在 JSON 转义双引号 \"...\"
例如,将您的 npm 脚本更改为以下内容:
"scripts": {
...,
"rls:on": "npm run typeorm query \"$(cat src/policies/enable-rls.sql)\""
^^ ^^
}