The script I'm writing will require me to pass some command line parameters. I would like to use these parameters within an array, but I'm not sure how.
A very basic example of this would be (script run as ./script.sh array1
):
#!/bin/bash
array1=( a b c d )
echo ${#$1[@]}
The output should be 4, but I receive the following error:
line 5: ${#$1[@]}: bad substitution
.
I don't have to use arrays, but would like to.
Thanks for any ideas