**已关闭。**此问题需要debugging details。目前不接受回答。
编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答问题。
18天前关门了。
Improve this question的
我想在PDF文件中搜索一些不同的词;使用pdfgrep https://pdfgrep.org/doc.html我可以做到这一点,但我不能运行很多次,一个为数组中存在的每个词。
然后我想保存在一个不同的单个文件的每一个输出。
#!/bin/bash
function search_elements(){
array=("$@")
for i in "${array[@]}";
do
pdfgrep -Hir ' "$i" ' .
done
}
array = ("gomma" "lacca" "bromo")
search_elements "$(array[@])"
字符串
这是ShellCheck的输出:
- 第5行:SC2034
for i in "${array[@]}";
^-- SC2034 (warning): i appears unused. Verify use (or export if used externally).
- 第7行:SC2016
pdfgrep -Hir ' "$i" ' .
^-- SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
array = ("gomma" "lacca" "bromo")
^-- SC2283 (error): Remove spaces around = to assign (or use [ ] to compare, or quote '=' if literal).
^-- SC1036 (error): '(' is invalid here. Did you forget to escape it?
^-- SC1088 (error): Parsing stopped here. Invalid use of parentheses?
1条答案
按热度按时间vptzau2j1#
这里是语法错误修复.
字符串
将逻辑放在函数中似乎有点像过度工程;这很简单,只需在脚本中使用您想要扫描的关键字调用。
型
这里没有使用Bash语法;
/bin/sh
在许多平台上更可移植,速度也更快。shellcheck警告是可点击的链接,其中包含有关每个错误的更多信息;请在请求人工帮助之前阅读它告诉您的内容。