Install multiple casks with homebrew looping through a defined list
I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.
I created a list of casks I need:
CASKS=(
transmission
vlc
)
I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing "$CASKS[@]
brew cask install $CASKS[@]
done
The script is not working as I want. On the terminal I can read:
Installing transmission vlc
whereas I'd like to see
Installing transmission...
(installation process going on...)
Installing VLC...
(installation process going on...)
Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.
How can I fix it?
shell terminal sh
add a comment |
I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.
I created a list of casks I need:
CASKS=(
transmission
vlc
)
I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing "$CASKS[@]
brew cask install $CASKS[@]
done
The script is not working as I want. On the terminal I can read:
Installing transmission vlc
whereas I'd like to see
Installing transmission...
(installation process going on...)
Installing VLC...
(installation process going on...)
Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.
How can I fix it?
shell terminal sh
add a comment |
I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.
I created a list of casks I need:
CASKS=(
transmission
vlc
)
I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing "$CASKS[@]
brew cask install $CASKS[@]
done
The script is not working as I want. On the terminal I can read:
Installing transmission vlc
whereas I'd like to see
Installing transmission...
(installation process going on...)
Installing VLC...
(installation process going on...)
Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.
How can I fix it?
shell terminal sh
I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.
I created a list of casks I need:
CASKS=(
transmission
vlc
)
I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing "$CASKS[@]
brew cask install $CASKS[@]
done
The script is not working as I want. On the terminal I can read:
Installing transmission vlc
whereas I'd like to see
Installing transmission...
(installation process going on...)
Installing VLC...
(installation process going on...)
Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.
How can I fix it?
shell terminal sh
shell terminal sh
edited Nov 11 at 13:05
asked Nov 11 at 12:57
teo-gamba
174
174
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You need to actually use your loop variable (i
) instead of referring to the whole array with $CASKS[@]
:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing $i"
brew cask install "$i"
done
Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"
). (This advice does not apply if your CASKS
array elements contain multiple words that are meant to be taken as separate arguments to brew cask install
; in that case you'd use brew cask install $i
without quotes.)
add a comment |
The looping way like this:
## declare an array variable
## can be on the same line or on multi-lines
declare -a arr=("zsh" "zsh-completions"
"ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
"asciidoc"
)
## now loop through the above array with use of the loop-variable `i`
for i in "$arr[@]"
do
echo "Installing $i..."
brew install $i
done
You could do it the easy way and just do this in a script:
brew install zsh
brew install zsh-completions
brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
brew install asciidoc
Just add a new brew install ...
line every time you add somthing so you can repeat it on a new machine...
I myself have two of these lists. One for the brew installs
and one for the brew cask installs
and it has served me just fine :-)
Thank you! what does thedeclare -a
stand for?
– teo-gamba
Nov 11 at 13:24
@teo-gamba It declaresarr
to be an array, butarr=( ... )
would do the same thing on its own, so it's redundant here.
– melpomene
Nov 11 at 13:26
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248965%2finstall-multiple-casks-with-homebrew-looping-through-a-defined-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to actually use your loop variable (i
) instead of referring to the whole array with $CASKS[@]
:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing $i"
brew cask install "$i"
done
Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"
). (This advice does not apply if your CASKS
array elements contain multiple words that are meant to be taken as separate arguments to brew cask install
; in that case you'd use brew cask install $i
without quotes.)
add a comment |
You need to actually use your loop variable (i
) instead of referring to the whole array with $CASKS[@]
:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing $i"
brew cask install "$i"
done
Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"
). (This advice does not apply if your CASKS
array elements contain multiple words that are meant to be taken as separate arguments to brew cask install
; in that case you'd use brew cask install $i
without quotes.)
add a comment |
You need to actually use your loop variable (i
) instead of referring to the whole array with $CASKS[@]
:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing $i"
brew cask install "$i"
done
Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"
). (This advice does not apply if your CASKS
array elements contain multiple words that are meant to be taken as separate arguments to brew cask install
; in that case you'd use brew cask install $i
without quotes.)
You need to actually use your loop variable (i
) instead of referring to the whole array with $CASKS[@]
:
echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing $i"
brew cask install "$i"
done
Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"
). (This advice does not apply if your CASKS
array elements contain multiple words that are meant to be taken as separate arguments to brew cask install
; in that case you'd use brew cask install $i
without quotes.)
answered Nov 11 at 13:16
melpomene
58.4k54489
58.4k54489
add a comment |
add a comment |
The looping way like this:
## declare an array variable
## can be on the same line or on multi-lines
declare -a arr=("zsh" "zsh-completions"
"ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
"asciidoc"
)
## now loop through the above array with use of the loop-variable `i`
for i in "$arr[@]"
do
echo "Installing $i..."
brew install $i
done
You could do it the easy way and just do this in a script:
brew install zsh
brew install zsh-completions
brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
brew install asciidoc
Just add a new brew install ...
line every time you add somthing so you can repeat it on a new machine...
I myself have two of these lists. One for the brew installs
and one for the brew cask installs
and it has served me just fine :-)
Thank you! what does thedeclare -a
stand for?
– teo-gamba
Nov 11 at 13:24
@teo-gamba It declaresarr
to be an array, butarr=( ... )
would do the same thing on its own, so it's redundant here.
– melpomene
Nov 11 at 13:26
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
add a comment |
The looping way like this:
## declare an array variable
## can be on the same line or on multi-lines
declare -a arr=("zsh" "zsh-completions"
"ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
"asciidoc"
)
## now loop through the above array with use of the loop-variable `i`
for i in "$arr[@]"
do
echo "Installing $i..."
brew install $i
done
You could do it the easy way and just do this in a script:
brew install zsh
brew install zsh-completions
brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
brew install asciidoc
Just add a new brew install ...
line every time you add somthing so you can repeat it on a new machine...
I myself have two of these lists. One for the brew installs
and one for the brew cask installs
and it has served me just fine :-)
Thank you! what does thedeclare -a
stand for?
– teo-gamba
Nov 11 at 13:24
@teo-gamba It declaresarr
to be an array, butarr=( ... )
would do the same thing on its own, so it's redundant here.
– melpomene
Nov 11 at 13:26
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
add a comment |
The looping way like this:
## declare an array variable
## can be on the same line or on multi-lines
declare -a arr=("zsh" "zsh-completions"
"ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
"asciidoc"
)
## now loop through the above array with use of the loop-variable `i`
for i in "$arr[@]"
do
echo "Installing $i..."
brew install $i
done
You could do it the easy way and just do this in a script:
brew install zsh
brew install zsh-completions
brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
brew install asciidoc
Just add a new brew install ...
line every time you add somthing so you can repeat it on a new machine...
I myself have two of these lists. One for the brew installs
and one for the brew cask installs
and it has served me just fine :-)
The looping way like this:
## declare an array variable
## can be on the same line or on multi-lines
declare -a arr=("zsh" "zsh-completions"
"ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
"asciidoc"
)
## now loop through the above array with use of the loop-variable `i`
for i in "$arr[@]"
do
echo "Installing $i..."
brew install $i
done
You could do it the easy way and just do this in a script:
brew install zsh
brew install zsh-completions
brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
brew install asciidoc
Just add a new brew install ...
line every time you add somthing so you can repeat it on a new machine...
I myself have two of these lists. One for the brew installs
and one for the brew cask installs
and it has served me just fine :-)
edited Nov 11 at 13:21
answered Nov 11 at 13:16
Ivonet
1,167518
1,167518
Thank you! what does thedeclare -a
stand for?
– teo-gamba
Nov 11 at 13:24
@teo-gamba It declaresarr
to be an array, butarr=( ... )
would do the same thing on its own, so it's redundant here.
– melpomene
Nov 11 at 13:26
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
add a comment |
Thank you! what does thedeclare -a
stand for?
– teo-gamba
Nov 11 at 13:24
@teo-gamba It declaresarr
to be an array, butarr=( ... )
would do the same thing on its own, so it's redundant here.
– melpomene
Nov 11 at 13:26
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
Thank you! what does the
declare -a
stand for?– teo-gamba
Nov 11 at 13:24
Thank you! what does the
declare -a
stand for?– teo-gamba
Nov 11 at 13:24
@teo-gamba It declares
arr
to be an array, but arr=( ... )
would do the same thing on its own, so it's redundant here.– melpomene
Nov 11 at 13:26
@teo-gamba It declares
arr
to be an array, but arr=( ... )
would do the same thing on its own, so it's redundant here.– melpomene
Nov 11 at 13:26
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
what @melpomene says. I like to be explicit though so there 😄
– Ivonet
Nov 11 at 13:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248965%2finstall-multiple-casks-with-homebrew-looping-through-a-defined-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown