10

When I run:

sudo /usr/local/nginx/sbin/nginx -t

I get back:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

I just want the last line so I run:

sudo /usr/local/nginx/sbin/nginx -t | sed -e '$!d'

But I get back the same as without sed.

13

Your command possibly outputs to stderr instead of stdout. To redirect stderr to stdout:

sudo /usr/local/nginx/sbin/nginx -t 2>&1 | sed -e '$!d'

If you only want the last line of your output, you can also use tail -n 1 instead of sed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.