Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run multiple brew commands with one line?

I often run the following commands, one after another. I wonder if it can be done with one line?

brew update
brew upgrade
brew cleanup
like image 575
Stickers Avatar asked Nov 23 '25 05:11

Stickers


2 Answers

To run every command one after another:

brew update; brew upgrade; brew cleanup

To stop immediately after one of the commands fail:

brew update && brew upgrade && brew cleanup

This way, if update succeeds, and then upgrade failed, the cleanup will not run.

Both will execute commands from left to right.

like image 152
Trevor Hickey Avatar answered Nov 24 '25 21:11

Trevor Hickey


Easily done. Just add a semi colon. So....

brew update; brew upgrade; brew cleanup;

This is the basics of writing your own BASH scripts. You can write complex scripts that are a single line.

echo thanks this is a test; echo ok here is new line, echo run another command here; ls; pwd; echo thanks i rock;
like image 32
technology101010 Avatar answered Nov 24 '25 21:11

technology101010