[thelist] bash, read from several file

Magnus Østergaard magnus at slackware.adsl.dk
Fri Apr 16 20:57:13 CDT 2004


Hi,

I am trying to populate a postgresql db with values from several files.
In each file, each line correspont to the same line number in the other
files.
The problem is how do I make my loop?

This is what I've got so far:

#!/bin/sh
while read name;
 do psql -d nobody nobody -c "INSERT INTO contact(name) VALUES('$name');" ;
done< ./name.txt

But this only reads one file.

How can I read from two files (or more) at one time. Say name.txt and
email.txt and then do.

"INSERT INTO contact(name,email) VALUES('$name','$email');"

I am looking for a bash solution, but a php one could help me.

// Magnus




More information about the thelist mailing list