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.
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.
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.