Answer the question
In order to leave comments, you need to log in
How to get bash variables from txt file?
I have a text file which contains 3 lines of text.
db
db_pass
db_pass
sudo mysqldump -u$username -p$password $database > $database.sql
Answer the question
In order to leave comments, you need to log in
You write variables to a file, as in a normal sh script - VAR1=foo, VAR2=bar, etc., and at the beginning of your script, say "source /path/to/varsfile", and all variables are pulled from there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question