til
til copied to clipboard
Check only nginx version from command line
Dễ, ai cũng biết
> nginx -v
nginx version: nginx/1.18.0
Vậy thử xử lý chuỗi qua pipe thì sao?
> nginx -v | awk -F '/' '{print $2}'
nginx version: nginx/1.18.0
??? sao không xử lý được ta? check help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
Do sau khi thực hiện command, thì exit luôn, nên không thể xử lý chuỗi đầu ra được, thay vào đó phải redirect ra stdout mới xử lý được
nginx -v 2>&1 | awk -F '/' '{print $2}'