Without () around your data you will never create an array in bash, unless you individually assign each value to a specific index.
So let us look at what you have done:
input=$1 :- here you assign the value of the first parameter to a variable. Great idea except then you never use the variable
myText=`cat $1` :- here you assign the contents of the file passed as first parameter to a variable. Note I said contents, hence the variable contains the entire file, newlines and all.
myArray=${#myText[*]} :- here you assign the length of an "array" to a variable. I quoted "array" as in fact it is only a string but bash will let you refer to it in the same way, however, here it will
return the value 1 as by definition there is only 1 index value (this being the zero'th value) which has all of your data stored in it.
If you want more proof that you have not created an array, try the following:
You will find the output to not be at all what you expected.
As shown by HMW, your commented out version, #myArray=( $(cat "$1") ), was actually the correct way to create an array.
My own preference would be (although the exact same outcome):
Code:
input="$1"
my_array=($(< "$input"))