I get confused about using command directly and using $(foo).
I'm using Mac, I try to list apps which is install by brew cask
(a package manager), and echo each app.
I have two short Shell scripts, first one like this:
#!/bin/bash
apps=$(brew cask list)
for app in ${apps}
do
echo "${app}"
done
It works fine, however another likes this:
#!/bin/bash
apps=$(brew cask list)
myecho=$(echo)
for app in ${apps}
do
${myecho} "${app}"
done
This one returns ./script2.sh: line 7: foo: command not found
, foo
is the name of app.
What's the difference between I use echo directly and using myecho
as a aliases?