I have 2 files with some content/lines.
Example :
cat a.txt
1
2
3
4
cat b.txt
a
b
c
d
Need to get below output using for loop
1 a
2 b
3 c
4 d
I have tried the below script but it gives the wrong output
for i in `cat a.txt`
do
for j in `cat b.txt`
do
echo $i and $j
done
done
1 and a
1 and b
1 and c
1 and d
2 and a
2 and b
2 and c
2 and d
3 and a
3 and b
3 and c
3 and d
4 and a
4 and b
4 and c
4 and d
Kindly help me to do with For loop. Thanks in Advance
paste a.txt b.txt
– ilkkachu Jun 15 '22 at 18:01paste -d ' ' a.txt b.txt
is "the wrong answer" for you, then please also explain why. There is absolutely no need for anyfor
loop to solve this. – Kusalananda Jun 15 '22 at 20:39paste
is not acceptable to you. – Kusalananda Jun 16 '22 at 07:38paste
or not usingfor
loops or asking for further clarifications as "not needed" is not an optimal communication method. If we understood why you needed afor
loop, then we would be able to formulate an answer that is ultimately helpful to you. As it stands right now, you have an answer that shows no fewer than 3 different ways to solve your issue (with variations), one of which employs a perfectly goodfor
loop. – Kusalananda Jun 16 '22 at 09:28