connor.roche connor.roche - 5 months ago 59
Bash Question

Can't pass /bin/*

I am trying to pass a to fill an array with a list of directories using a simple shell script. However when I pass

into the program as the first parameter
turn to
(the first directory in /bin). My code is below for reference. Can I not pass
in a parameter?


declare -a d

for filename in ${1}; do

echo "$1"

The result of the echo is


Answer Source

* is being expanded by the shell before it calls your script. Try calling as yourscript '/bin/*' (note the quotes).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download