user3562926
user3562926

Reputation: 77

How can I assign the output of this command to a variable in Shell?

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

Upvotes: 0

Views: 61

Answers (1)

Sean Bright
Sean Bright

Reputation: 120644

POM_ERRORS=$(egrep -e "\\\\" pom.xml | egrep -v -e "\\\\$")

Upvotes: 2

Related Questions