service ssh status > /dev/null || sudo service ssh start
A script that runs the SSH service on the Linux cli.
The middle ||
operator is OR, right?
How does it work if the ||
operator is inserted between two commands, not just any conditional statement?
If you actually do it, there's nothing that stands out except for the start of SSH.
bash
a || b
Run the a command first, and then run b only if the exit status of the command is not zero.
It's like a historical tradition, where a program returns an end state of zero if it's working as intended until the end, and a non-zero number if it's terminated in the middle with some exception.
Remember that after you run a, b only runs when it doesn't work normally.
© 2024 OneMinuteCode. All rights reserved.