How do I use a file grep comparison inside a bash if/else statement?

Posted by openid_kenja on Stack Overflow See other posts from Stack Overflow or by openid_kenja
Published on 2010-03-19T21:06:22Z Indexed on 2010/03/19 21:11 UTC
Read the original article Hit count: 138

Filed under:

When our server comes up we need to check a file to see how the server is configured.

We want to search for the following string inside our /etc/aws/hosts.conf file:

MYSQL_ROLE=master

Then, we want to test whether that string exists and use an if/else statement to run one of two options depending on whether the string exists or not.

What is the BASH syntax for the if statement?

if [ ????? ]; then
  #do one thing
else
  #do another thing
fi

© Stack Overflow or respective owner

Related posts about bash