Reputation: 63
so, i have two text file containing
title1
title2
stored in title.txt
and
data1
data2
stored in data.txt
and i'd like to join it with cat
, so it gonna look like this
title1 | data1
title2 | data2
but, the regular cat title.txt data.txt > out.txt
turns the out.txt file into
title1
title2
data1
data2
i need help on using the cat
so the file can look like this:
title1 | data1
title2 | data2
any answer will be appreciated
Thanks
Upvotes: 0
Views: 329
Reputation: 85
Use while loop to read from both
while IFS= read -r line && IFS= read -r line1 <&3;
do
title=`echo -ne $line`;
data=`echo -ne "$line1"`;
echo "$title | $data" > output.txt
done <data.txt" 3<title.txt"
Upvotes: 0
Reputation: 123508
Try saying:
paste -d'|' title.txt data.txt
For your input, it should return:
title1|data1
title2|data2
Upvotes: 3