Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
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" ?
 
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?

Code:
find . -type d -depth 1 -name 'Documents'; say 'command executed'
even though, at least in this case, in practice it looked to me as if it did exactly what && (||) should be used for?
 
while a pipe is performing them "in parallel" ?
Correct. Totally bogus example (take echo output and pass that to tr command to change the case):

Code:
% echo 'hello world' | tr '[:lower:]' '[:upper:]'
HELLO WORLD
%
 
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?
Those are more useful in scripts, to execute something if successful and something else if unsuccessful.
I just want to know when it’s over :)
 
i hope you don't get me wrong, it wasn't meant as criticism (i don't even have the slightest bit of knowledge to base that upon)
i just wanted to understand things better, and && just looked "more appropriate" "on paper", while the semicolon not necessarily so, despite (at least in this case?) working pretty much the same as i would have expected && to work, at least based on their descriptions, since just "having pressed the enter key" doesn't necessarily mean that the command has already been finished.
but i think in practice you should get the prompt to enter something new only after a previously entered command has been finished/aborted/exited anyway, so the "basically like pressing the ENTER key to execute a command." - part mislead me thinking it was meant to be just right after having pressed the enter key in a purely physical way, completely disregarding what an OS does until the next prompt line appears
 
&& just looked "more appropriate" "on paper", while the semicolon not necessarily so,
Appropiate is defined by what you want to achieve. To recap:
- the command after ; is executed regardless of the result before
- the command after && is executed only if the one before is successful
- the command after || is executed only if the one before is unsuccessful
You can link them:
Code:
ls -0 && say 'command succeded' || say 'command failed'

ls -o && say 'command succeded' || say 'command failed'
 
yup, i was just irritated by the (paraphrased) "basically comparable to having pressed enter" part of the semicolon description.
there is a slight perceived difference between "just having pressed enter" after a simple directory creation command, and a command that is formatting a 10TB hard drive.
In both cases, the next step will only start after the previous is finished, because the OS only accepts a new command after completion of another, even though one of them might take only fractions of a second and it's indeed comparable to "just having pressed enter", the other could take several hours, where many people could perceive the next step occurring not exactly after just a press on the enter key (even though it technically still is, just after a long-ish delay)

oh and once again great examples from you, as always! 👍
 
really gotten to like unix in the last couple of days 💕😂

would love to try my luck on kill(all) next, but the process is sounding so... violent! 🤣
any dos and don'ts to keep in mind?
is it really safe to killall running processes like let's say Pages, or if i should become really daring: killall Dock
without having to be afraid of some glitches or system crashes?

from what i gather, kill = kill process by process ID, killall by process name?
 
ok, the daredevil inside me just won and i killall'ed the Terminal🤘
(after reading some more about that command beforehand 🤡)

to my surprise, my Macbook survived 😱, but now i wonder, what does killall do exactly?
when i start the terminal again, a line appears that the session has been recovered
so is killall (without any further modifiers) equivalent to "force quit"?

from what i've read, it's supposed to be -15 by default, letting apps still store their stuff "regularly" before they quit?
and what would happen if i killalled Finder? will it automatically re-appear like it does when i force quit it from macOS's GUI part?
 
“killall – kill processes by name”

Code:
killall 'Terminal'
terminates Terminal, it will not restart

Finder and Dock will restart, and the commands are useful sometimes to fix glitches
Code:
killall 'Finder'

Code:
 killall 'Dock'

An unsafe one was
Code:
sudo killall 'WindowServer'
that was a forced log out, but it doesn’t seem to be working in Monterey.
 
Finder and Dock will restart, and the commands are useful sometimes to fix glitches
thanks! 😊

An unsafe one was
sudo killall 'WindowServer'
would that auto-restart too?
new to Mac, but i thought WindowServer was basically a "graphics driver", or at least the interface between your graphics chip and your screen?
might become a bit problematic if it just quit i'd think?
 
might become a bit problematic if it just quit i'd think?
In the category “don’t try this at home”.
(use a virtual machine for potentially unsafe tests)
you can force close WindowServer from Activity Monitor and it will auto-restart, but the user will be logged out instantly, causing all open apps to potentially lose unsaved changes.
From Terminal, WindowServer can be stoped/restarted in Monterey using launchctl. Stoping it leaves you with a black screen and you have to force shutdown from the physical button. Restarting has the same behavior as force close from Activity Monitor.
 
thanks,
i don't have serious intentions trying this, i was just curious how it worked! 👍
if i should run into problems that required me to kill WindowServer, i guess i would rather just give my system a new cold start instead.
 
  • Like
Reactions: bogdanw
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/
Keep in mind what’s written on the bottom of the page:
“Commands marked • are bash built-in commands. bash is the default shell, it runs under Darwin the open source core of macOS.
In macOS Catalina the default shell will change to zsh and in time this page will be updated to include that.”
 
now that you mention bash:
just a couple of days ago, while examining some of the command binaries inside the /bin/ directory, the first executable i had to launch has been bash
then immediately without any need for user confirmation, some message in the line of "the shell has been converted to bash... to revert back, use some *forgot what it actually was thingie* command" appeared

i take it the z shell is usually the default one on Monterey?

launching the zsh binary seems to be accepted, but the shell doesn't give any feedback at all, wether that command has been successfully executed, but it also doesn't it give any error messages either

does this mean that i now "downgraded" from zsh to bash?

haven't noticed any different behavior than before and the few commands i'm familiar with seem to still work all the same
 
Hello. Very interesting thread. I'm also new to MacOS, having only owned a Windows device before. I want to ask, what do you use the Terminal and its commands for? Is it even necessary to use it for normal activities or is it more of a MacOS debugging tool? Thank you.
 
welcome on board 👍

as bogdanw has mentioned, it is not really necessary (for everyone)
But depending on your needs regarding your operating system, it can be a very powerful tool.
But it's more for people who are into (or need) digging deeper than what the beautiful and streamlined graphical user interfaces of modern graphical user interfaces provide you on their surface.

the best practical example i can give you is in my signature
I'm a beginner myself - and it doesn't quite work yet as expected, but i'm still working on it! 🤓

so if you are more the tweaker / coder / system administrator kind of guy / gal - or want to get into it, then Terminal might be for you.
Otherwise for most other people, macOS's "default view" is the only thing they'd really want to tinker with
 
while looking at this website:

i became curious if it is possible to curl a website incl. all linked pages into a working (set of) offline .html?

the man page for curl is quite gargantuan and i'm having a feeling that it might also not work on it's own without piping into some other command(s)?

(not of utmost importance, as i can easily view that site online, but still... 🤪)
 
There is one thing I would like to modify on my signature device. I'm using MacOS Mojave and the Spotlight icon is displayed in the Menubar. I would like to delete this icon, but it cannot be done in the usual way. Can it be removed using Terminal commands? Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.