Quote:
|
Originally Posted by supinformix
open different file descriptors :
exec 3 <f1
exec 4 <f2
exec 5 <f3
while read F1
do
read F2 < &4
read F3 < &5
echo "$F1 \n $F2 \n $F3" >>output
done < &3
problem is what if file f2 has less rows than f1.
|
You can get round that something like this...
Code:
exec 3<file1 4<file2 5<file3
while read file1Var <&3 && isVarRead=true;
read file2Var <&4 && isVarRead=true;
read file3Var <&5 && isVarRead=true;
${isVarRead-false}
do
print ${file1Var} ${file2Var} ${file3Var}
unset isVarRead
done
Admittedly, this does the same as 'paste' but it allows you to tinker with the 'print' line to output exactly what you would like.
You could also use awk, e.g. while (getline < "file1" > 0) { ...
Damian