Categories Current Searches How to display nc return value in Linux shell script? Post author By Mike Nova Post date September 11, 2025 I am using nc command in my Linux box like below to check if a port is listening; This displays success message: nc -z 192.168.0.2 9000 This displays 0: echo $? I have combined it in a shell scr…