【发布时间】:2021-09-11 14:45:14
【问题描述】:
#!/bin/bash
filename='delete'
while read p; do
jq 'if .tweet | test('\"$p\"'; "i") then . |= . + {vendor: '\"$p\"'} else empty end' sfilter.json
done < $filename
当我使用 variable = "hello world" 但不是 "hello" 时,我不断收到此错误 简而言之,只要字母中有空格,就会导致此错误。
但是直接在shell上执行似乎没有错误。
jq: error: syntax error, unexpected $end, expecting QQSTRING_TEXT or QQSTRING_INTERP_START or QQSTRING_END (Unix shell quoting issues?) at <top-level>, line 1:
if .tweet | test("sdas
jq: 1 compile error
但是当我在 shell 上运行命令时,它运行良好。有什么想法吗?
编辑: 输入删除文件
sdas 广告
【问题讨论】:
-
请分享输入文件。
-
@0stone0 完成添加输入文件。