txt 1:
abc
trt
prc etc
txt 2:
1
2
3 etc
txt 3:
abc1
abc2
abc3
trt1
trt2
trt3
prc1
prc2
prc3 etc
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitytxt 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)