Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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.

#!/bin/bash
u=`cat newlist`
for i in $u 
do
echo ""
echo ",'$i'"

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

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
add comment

2 Answers

up vote 4 down vote accepted
#!/bin/bash
exec 8<passwordfile
while read user
do
    read password <&8
    echo $user
    echo $password
done <usersfile
share|improve this answer
1  
That's quite elegant. –  Eduardo Ivanec May 5 '11 at 17:38
    
Thanks lain for you help. –  User4283 May 5 '11 at 17:43
add comment

paste

Also, BASH FAQ entry #1.

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

Your Answer

 
discard

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.