Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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.