On 12/27/2016 11:49 PM, JD wrote:
Reading lines from 2 files in such a way that each iteration
lets me read the next line from each file so that the items
read from each file are in sync as far as line number is concerned.
Is this "doable"?
For a single file, indexing to next line is automatic, visa vis
while read line; do
done < some_file.txt
for when more than 1 file is involved, it is not so easy ...
If using the bash, you could introduce file descriptors for each file
you are reading from ( set the fie descriptor by using the exec command)
and then read using the -u option for each file.
Hypothetical (of course, non-working example):
while true do;
file_A_line=`read line$index` # Read from file A
file_B_line=`read line$index` # read from file B
[ x$file_A_line = x -o x$file_B_line = x ] && break
<do something withfile_A_line and file_B_line>
index=`expr $index + 1`
So how can the reading from 2 files be accomplished and keep the index
to next line in sync?
I know it is a no brainer with a C program.
users mailing list -- users(a)lists.fedoraproject.org
To unsubscribe send an email to users-leave(a)lists.fedoraproject.org
Fedora release 25 (Twenty Five)
Joachim Backes <joachim.backes(a)rhrk.uni-kl.de>