I have two text files of the same length, in order: one of products, the other of comparison products. I'd like the output to be product;comparison for each line. Yes I could throw them in a spreadsheet and export as csv, but I'd like to understand how to do it in bash. The two files are supplied as arguments.#!/bin/bashfile1=$1;file2=$2;separator=;;while read -r productdo  read -r comp < $file2;  echo $product $separator $comp >> temp.txt;done < $file1tr -d   < temp.txt | sort > out.txtrm temp.txtThis gives me all the products with the same comparison product! Eg $: cat out.txtproduct1;comp1product2;comp1product3;comp1I'm obviously not reading the single line of the comp file properly - what am I doing wrong? How do I read a single line?
Read two text files, concatenate each line
shell script;text processing
If you really want to do it in bash, I'd suggest making use of the -u fd option to read from the two files simultaneously using numbered streams, e.g.while read -r -u3 product; read -r -u4 comp; do   printf '%s;%s\n' $product $compdone 3<products.txt 4<comps.txtHowever, you could just use the paste utilitypaste -d\; products.txt comps.txt