Another bonus for the && syntax is that if the first command fails it will not run the second command.
This is useful if the second command relies on the first commands result (Like with your example updating packages).
If they're two separate commands that don't rely on each other then you can use ; instead.
;
I use that with gcc. gcc filename.c && ./a.out
If compilation failed, it won't run the program.
Also || is a valuable tool on scripts, to exit or inform an error:
do_something_amazing || echo “nope” && exit 1
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Another bonus for the && syntax is that if the first command fails it will not run the second command.
This is useful if the second command relies on the first commands result (Like with your example updating packages).
If they're two separate commands that don't rely on each other then you can use
;
instead.I use that with gcc.
gcc filename.c && ./a.out
If compilation failed, it won't run the program.
Also || is a valuable tool on scripts, to exit or inform an error:
do_something_amazing || echo “nope” && exit 1