03-08-2024, 01:34 PM
I'm currently learning Bash scripting and have come across a scenario where I need to run certain database operations on a set of database names. I thought of storing these names in an array and then looping through it to apply the operation. However, my knowledge of arrays and loops in Bash is quite limited. Here's the basic pseudo-code I have in mind, but I'm not sure how to properly declare the array and use it in the loop. Can someone provide me with a correctly formatted Bash script that would work for looping through, say, 15 database names?
I'd appreciate it if the shared code could include some basic operations like echoing the database name just to confirm the loop is working, and comments to explain what each part of the script is doing.
Code:
pseudo
for databaseName in listOfNames
then
# Do something with databaseName
end
I'd appreciate it if the shared code could include some basic operations like echoing the database name just to confirm the loop is working, and comments to explain what each part of the script is doing.