-1

I am trying to make a checkpoint management script, which will delete all checkpoints that are over 3 days old for a variety of databases. I want to keep the code in one script and then keep a list of all the paths to each database I want to manage in another.

How do I reference the file with the list of databases, so I can use them in a for loop? In the loop, how do I change directories to each directory listed in the text file?

Ex. File with list of databases (db.list):

/directory/directory/databse1

/directory/directory/databse4

/directory/directory/databse10

Ex. Code:

for database in db.list

do
   cd $database
   code

done 
0

1 Answer 1

3

A file listing database paths wouldn't be called a script. It just a text file.

To iterate over lines of a text file, you can read the file:

while read -r database ; do
    echo "$database"
done < db.list
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.