': not a valid identifier

I am trying to write a bash script. I am able to do simple things like pass arguments, assign variables and echo the results. However, when I try to declare and array or anything a little more complicated I get
': not a valid identifier

Here is my code so far:

#!/bin/bash
echo start t
declare -a ARRAY
echo end t

And when I execute the script I get:

start t
': not a valid identifier
end t

My plan is to make a script that reads a file on line at a time and output's only part of each line to another file. It doesn't seem like it should be hard. But I can't get anything to work.

It looks like t is evaluating to :

When you write code, and you are new to coding, or to a system, you need to be careful of lowercase short variable names or words outside of quotes...

$#!/bin/bash
echo "start t"
declare -a ARRAY

echo "end t"
exit 0

Also start your script with a first line that is a shebang - in your case #!/bin/bash or maybe /usr/bin/sh. This makes the script ALWAYS run under the same shell. You may think this is a waste, but it is important. End with exit 0.

You probabally could use sed or awk or something else depending on what the file looks like.

Jim:
Thanks for your input. However, putting the text in quotes produces the same results.

Adding the exit 0 line will only shut my session down.

Ikon: Thanks. I'll look into usin sed or awk.

Try:

#!/bin/bash
echo "start t"
set -a ARRAY
echo "end t"

Thanks Icon! That worked. Do you have any idea why I couldn't use declare?

On our HP-UX servers we use korn shell and had same problem.

We've been using the korn shell for a lot of years on HP-UX as well. However, we've recently switched to Linux. Our new admins want us to start using bash although we still have access to ksh.