【发布时间】:2014-04-30 18:54:23
【问题描述】:
我有以下命令:
egrep -e "\\\\" pom.xml | egrep -v -e "\\\\$"
我想将它分配给一个变量,以便稍后在这段代码中回显它:
egrep -e "\\\\" pom.xml | egrep -v -e "\\\\$" &> /dev/null
if [ $? == 0 ]; then
echo "Errors in POM were found"
echo "line matches (result of the command)"
fi
【问题讨论】:
-
请注意,根据您的 shell 及其版本,管道的返回值可能是第一个命令或最后一个命令。您可能只需在第一个 grep 中的模式末尾添加一个句点并获得相同的结果。
-
我会考虑的,谢谢!