I want to write a script that loops through 15 strings (array possibly?) is that possible?
Something like:
for databaseName in listOfNames
then
# do something
end
|
You can use it like this:
|
|||||||||||||||||
|
That is possible, of course.
See Bash Loops for, while and until for details. |
|||||||||||||||||||||
|
In the same spirit as 4ndrew's answer:
B. No whitespace in the names:
Notes
Other ways to bring in data include: Read from stdin
Sides Notes
Other Sources (while read loop) |
|||||||||
|
None of those answers include a counter...
Output:
|
||||
You can use the syntax of
|
||||
|
The declare array dont work for Korn shell. Use the below for example for korn shell:
|
|||||||||||||
|
Try this working and tested.
|
|||
|
If you are using Korn shell, there is "set -A databaseName ", else there is "declare -a databaseName" To write a script working on all shells,
It should be work on all shells. |
|||
|
This is also easy to read:
|
|||
|
Possible first line of every bash script/session:
Use e.g.:
May consider: |
|||
|
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?