I wonder what the difference between
"echo 'hello'; ls"
and
"echo 'hello' && ls"
is? they both do the same thing
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“echo ‘hello’ && ls” means : execute “ls” if “echo ‘hello'” runs successfully. To understand what is “successful” in bash. Try this :
bash> cd /
bash> echo $?
if the previous command runs successfully, you should see 0
After that, try this :
bash> asdfdf
bash> echo $?
You should see a non-zero value between 1 and 255. This means previous command didn’t run successfully
On the other hand, “echo ‘hello’; ls” means execute “ls” whether “echo ‘hello'” runs successfully or not.