Strangely enough this wont work for me.
nginx -t | grep -c 'successful' | awk '{if ($0==0) print "not found"; else if ($0>0) print "found"}'
It returns a not found even though the result is as follows:
nginx: [warn] conflicting server name "xxx.co.za" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "xxx.co.za" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
not found
Even a simple grep doesn't do whats expected..
(nginx -t | grep -q 'successful') && echo "Yes" || echo "Nope"
Any idea how I can check if the nginx -t command is successful or not?