Today I've noticed that I can't use "awk" on "nginx -v".
I've tried running this command: nginx -v | awk -F/ '{print $2}'
This should of been output like this: nginx/1.4.3
But instead it gives me nginx version: nginx/1.4.3
Any idea why it would behave this way !?
Also you can't output it to file by running: nginx -v > file.txt
nginx must be writing that message to standard error, not standard output. If you want to pipe it, you have to redirect stderr to stdout:
nginx -v 2>&1 | awk -F/ '{print $2}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With