txt 1:
abc
trt
prc etc
txt 2:
1
2
3 etc
txt 3:
abc1
abc2
abc3
trt1
trt2
trt3
prc1
prc2
prc3 etc
txt 1:
abc
trt
prc etc
txt 2:
1
2
3 etc
txt 3:
abc1
abc2
abc3
trt1
trt2
trt3
prc1
prc2
prc3 etc
If the files can fit in memory:
perl -e 'chomp (@a = <STDIN>); @b = <>;
for $a (@a) {for $b (@b) {print $a,$b}}' < 'txt 1' 'txt 2'
Or if the Cartesian product can fit in memory, in zsh
:
a=( ${(f)"$(<'txt 1')"} )
b=( ${(f)"$(<'txt 2')"} )
print -rC1 -- $^a$^b
(that one removes empty lines for both files)
parallel -a first_f -a second_f echo {1}{2}
. – Prabhjot Singh Oct 31 '22 at 18:09