在sed
,您可以使用标志结束命令"/i"
(例如,请参阅此其他问题).这似乎说"更多sed命令即将发布",或类似的东西,因此您可以在脚本中拆分sed命令.或许不是 - 我找不到关于这面旗帜的任何文件.
在Mac OS X上,我有一个像这样的bash脚本:
# Directories excluded from grep go here.
EXCLUDEDIR="--exclude-dir={node_modules,.git,tmp,angular*,icons,server,coffee}"
# This grep needs to include one line below the hit.
grep -iIrn -A1 $EXCLUDEDIR -e "class=[\"\']title[\"\']>$" -e "<div class=\"content" . > microcopy.txt
Run Code Online (Sandbox Code Playgroud)
但它似乎无视$EXCLUDEDIR
.如果我只是--exclude-dir
直接使用它,它的工作原理.为什么不扩展变量并正常工作?