I have a simple file called dbs.txt I want to echo the lines of that file to the screen using a for loop in bash.
The file looks like this:
db1
db2
db3
db4
The bash file is called test.sh it looks like this
for i in 'cat dbs.txt'; do
echo $i
done
wait
When I run the file by typing:
bash test.sh
I get the terminal output:
cat dbs.txt
instead of the hoped for
db1
db2
db3
db4
The following bash file works great:
cat dbs.txt | while read line
do
echo "$line"
done
Why doesn't the first script work?
while readinstead offor i in $(cat dbs.txt)cat dbs.txt; do echo $i done wait</pre>