0

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

user1072976
  • 63
  • 2
  • 8

2 Answers2

3

Try saying:

paste -d'|' title.txt data.txt

For your input, it should return:

title1|data1
title2|data2
devnull
  • 118,548
  • 33
  • 236
  • 227
0

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"
Majlik
  • 1,082
  • 1
  • 10
  • 20
rmaan
  • 79
  • 1
  • 8