I would like to read the contents of two files using a loop but it doesn't seem to be working. Please have a look at the following script and help me resolve the problem.
While read Rec, Rec1
do
echo $Rec
echo $Rec1
---
----
---
done < file1, file2
I also tried this
for Rec in `cat file1` && Rec1 in `cat file2`
do
echo $Rec
echo $Rec1
---
----
done
I have one more problem with this script, how do know the EOF in shell scripts.
I don't want to display the records if one of the files reaches the end.
IFS="|"
paste -d\| file1 file2 |
while read line1 line2 ; do
if [ -z "$line1" ]; then
break
fi
if [ -z "$line2" ]; then
break
fi
echo FILE1: $line1
echo FILE2: $line2
done
This'll terminate as soon as one file has a blank line or EOF...
is that good enough?