Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
当前代码存在一些问题:
awk
需要一个文件作为输入,但modHTML
是一个(字符串)变量;要让awk
处理变量,您可以使用此处字符串来模拟将字符串作为文件提供给awk
,例如:awk '/Update: /{ p=1}p' <<< "$modHTML"
modHTML="xmllint --nowarning ..."
正在将字符串xmllint --nowarning ...
分配给modHTML< /code> 当您真正想要的是运行
xmllint
调用并将结果存储在modHTML
变量中时,例如modHTML=$(xmllint --nowarning ...)
将这些更改滚动到OP的当前代码:
注释:
xmllint
,因此我无法评论这是否是有效的调用,但至少建议的代码更改应该允许OP为了更接近期望的结果,awk
调用以提供更紧凑的答案,但我将把它留给OP来处理(一旦我们通过了语法错误并开始生成实际输出)Couple issues with the current code:
awk
expects a file as input butmodHTML
is a (string) variable; to haveawk
process a variable you can use a here-string to simulate feeding the string as a file toawk
, eg:awk '/Update: /{p=1}p' <<< "$modHTML"
modHTML="xmllint --nowarning ..."
is assigning the stringxmllint --nowarning ...
tomodHTML
when what you really want is to run thexmllint
call and store the results in themodHTML
variable, eg,modHTML=$(xmllint --nowarning ...)
Rolling these changes into OP's current code:
NOTES:
xmllint
so I can't comment on whether or not this is a valid call but at least the proposed code changes should allow the OP to get a bit closer to the desired resultawk
call can probably be tweaked to provide a more compact answer but I'll leave that up to the OP to work on (once we get past the syntax errors and start generating actual output)