Login using Social Account
     Continue with GoogleLogin using your credentials
Say, you want to execute a command only if another command is successful then you use &&
.
And if you want a command to be executed if another command has failed, you use ||
.
Create a file tea_ready
:
touch tea_ready
The following command would print "Tea is ready" if tea_ready
file exists:
ls -l tea_ready && echo "Tea is ready"
Delete the file tea_ready
:
rm tea_ready
Check the command from #2 again:
ls -l tea_ready && echo "Tea is ready"
The following will print "Tea is not ready":
ls -l tea_ready || echo "Tea is not ready"
You can use brackets to avoid confusion:
(ls -l tea_ready && echo "Tea is ready") || echo "Tea is not ready"
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Loading comments...