When unixshell detects the returned code and runs any command, linux returns the response related to the execution of the previous command, called the return code (returncode). how can this code be returned? Simple. use $? You can view the results. you can view the results. if the command successfully runs the unix shell learning check and returns the code. when you run any command, linux returns the response of the previous command execution, it is called return code. how can I get back to the code? Simple. use $? You can view it. you can view it. if the command is successfully executed, the return code is 0. if the command is not successfully executed, a value other than 0 is returned. We can use a small example in the book to perform a test. the following code writes three different if statements to better learn shell, but their functions are the same. #! /Bin/bashtest-d/usr/local/binif ["$? "-Eq 0] then echo"/usr/local/bin exist! "Else echo"/usr/local/bin does not exist! "Fi # --------------------------------------- if test-d/usr/local/binthen echo"/usr/local/bin exist! "Else echo"/usr/local/bin does not exist! "Fi # ------------------------------------- if [-d/usr/local/bin] then echo"/usr/local/bin exist! "Else echo"/usr/local/bin does not exist! "Fi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.