Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've two text files and I want to put each line from both files as output i.e.

u=`cat newlist`
for i in $u 
echo ""
echo ",'$i'"

for b in $( cat password )
echo ",'$b'"

Output should be

abc - from Users file 'line # 1'
123 - from password file 'line # 1'

Any help please

share|improve this question
Do you want to print the 1st line from each file followed by the 2nd line from each and so on ? – Iain May 5 '11 at 17:21
Yes exactly. you got my point. – User4283 May 5 '11 at 17:24
up vote 4 down vote accepted
exec 8<passwordfile
while read user
    read password <&8
    echo $user
    echo $password
done <usersfile
share|improve this answer
That's quite elegant. – Eduardo Ivanec May 5 '11 at 17:38
Thanks lain for you help. – User4283 May 5 '11 at 17:43


Also, BASH FAQ entry #1.

share|improve this answer
Also, that code snippet makes me want to gouge out my eyes. – Ignacio Vazquez-Abrams May 5 '11 at 17:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.