Question

I have a script that I execute by:

./myscript.sh database table  

This script receives two values $1 and $2

I also have a textfile.txt containing something like this:

database1 table1  
database2 table2  
database3 table3  
database4 table4  
...  
...  
...

I would like to pass the data contained in textfile.txt to my script in one command from the shell. I was thinking something like this:

./myscript.sh | cat textfile.txt

But does not work. Any ideas? Thank you!

Was it helpful?

Solution

You need to run a loop:

while read -r db table; do
    ./myscript.sh $db $table
done < textfile.txt 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top