am i right in my first assumption that a semicolon is putting commands in serial, performing each consecutive command only after the previous one is finished, while a pipe is performing them "in parallel" ?
When the shell sees a semicolon ; on a command line, it's treated as a command separator -- basically like pressing the ENTER key to execute a command.
Two related operators, && and ||, work like a semicolon, but they only execute the next command if the previous one succeeded or failed, respectively.
even though, at least in this case, in practice it looked to me as if it did exactly what && (||) should be used for?Code:find . -type d -depth 1 -name 'Documents'; say 'command executed'
Correct. Totally bogus example (take echo output and pass that to tr command to change the case):while a pipe is performing them "in parallel" ?
% echo 'hello world' | tr '[:lower:]' '[:upper:]'
HELLO WORLD
%
Those are more useful in scripts, to execute something if successful and something else if unsuccessful.i see (at least i hope so 😭)
but wouldn't then an && or || have been more appropriate in the example you have given in post #75?
even though, at least in this case, in practice it looked to me as if it did exactly what && (||) should be used for?
Appropiate is defined by what you want to achieve. To recap:&& just looked "more appropriate" "on paper", while the semicolon not necessarily so,
ls -0 && say 'command succeded' || say 'command failed'
ls -o && say 'command succeded' || say 'command failed'
killall 'Terminal'
killall 'Finder'
killall 'Dock'
sudo killall 'WindowServer'
thanks! 😊Finder and Dock will restart, and the commands are useful sometimes to fix glitches
would that auto-restart too?An unsafe one was
sudo killall 'WindowServer'
In the category “don’t try this at home”.might become a bit problematic if it just quit i'd think?
Keep in mind what’s written on the bottom of the page:in case it is of interest for anyone else as well, i just found a pretty extensive list of macOS shell commands, including their manuals (man command descriptions) :
https://ss64.com/osx/
Yes, /bin/zsh is the default. No, you have not been switched to bash. Check in Terminal preferences https://support.apple.com/guide/terminal/change-the-default-shell-trml113/2.12/mac/11.0does this mean that i now "downgraded" from zsh to bash?
$SHELL --version
🤘zsh 5.8.1
No, it’s not necessary, but it can be useful.Is it even necessary to use it for normal activities