Shell script problem
Nils Kassube
kassube at gmx.net
Tue Mar 2 07:28:02 UTC 2010
Patton Echols wrote:
> First, the declare command at the beginning of the script throws a
> "not found" Is that an error?
The command wants to declare an array but arrays are only available in
bash, not in sh (more specific in bash 2.0 or newer). That is the main
problem and it was mentioned already by Markus Schönhaber. With Ubuntu
we have /bin/sh linked to /bin/dash which doesn't have the bash
extensions. Therefore, if you want to use bash specific commands, you
have to use "#!/bin/bash" at the beginning of your script.
> I do not know enough about assigning array variables to troubleshoot.
> I am going to do a little searching after posting this, but since
> my "self education" comes in fits and starts, thought others might
> want to take a look sooner.
For self education I would suggest you read the O'Reilly book "Learning
the bash Shell". It doesn't mention which features are bash specific
though. As I usually don't need portable scripts that would run on
machines without bash, I don't mind that I don't know which feature is
bash specific. I just prepend my scripts with "#!/bin/bash". As an
alternative you can read the bash manual online at [1], but I prefer
books for learning.
Nils
[1] <http://www.gnu.org/software/bash/manual/>
More information about the ubuntu-users
mailing list