troubleshooting Question

Interpreting $? output in bash shell

Avatar of beer9
beer9Flag for India asked on
Shell Scripting
2 Comments2 Solutions153 ViewsLast Modified:
Hello, I am running a command using pipe, say

echo stats | nc hostname.com 1001
echo $?

and then I am getting the output of $? as 0. so here $? is depends on which command? echo or nc?? for getting $? 0 does both command needs to be executed successfully or either of nc or echo would do? how does $? gets evaluated in piping. Thanks!
ASKER CERTIFIED SOLUTION
Garry Glendown
Consulting and Network/Security Specialist

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros