rated 0 times [ 1074] [ 0] / answers: 3 / hits: 478978 / 8 Months ago, thu, october 20, 2022, 1:44:12
In tutorials and how-to's I often see commands combined. For instance,
sudo apt-get update && sudo apt-get install pyrenamer
There seem to be four possible connectors:
;. Though the
& connector is clear to me (it sends a process to the background and leaves the terminal available), it is not clear what the difference is between
;. And I did not know of
|| until Kaya's comment.
The following questions deal with the difference between the two connectors, but do so mostly in the comments:
So here are a number of related questions:
- What is the difference between
- When should you use them respectively? It would be nice to see some use cases: if I want to run a command and then after it shutdown my computer, which connector should I choose?
- What are their advantages and dangers? Robie Basak mentions in a comment to this answer that a command like
cd /somewhere_else; rm -Rf *can have destructive consequences if the first element in the command chain fails, for instance.
- If relevant, where do they come from?
More From » command-line