0

I have the following command:

egrep -e "\\\\" pom.xml | egrep -v -e "\\\\$"

I want to assign it to a variable so that I can echo it later in this code:

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
1
  • Be aware that, depending on your shell and the version thereof, the return value of the pipeline could be the first command or the last command. You could probably just stick a period at the end of your pattern in the first grep and have the same result. Commented Apr 30, 2014 at 19:05

1 Answer 1

2
POM_ERRORS=$(egrep -e "\\\\" pom.xml | egrep -v -e "\\\\$")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.