# assuming ".ext" extension
for file in *.ext
do
cat $file | while read line
do
if [ "$CUST" = "" ]
then
CUST=$line
fi
if [ "$INFO1" = "" ]
then
INFO1=$line
fi
# repeat the following as many times as you need
# for INFO3, INFO4 etc
if [ "$INFO2" = "" ]
then
INFO2=$line
fi
done
# vars have been read for this file, now for output.
# if you need to output all to one file, define it above
# outside the loops as OUTFILE=/path/to/outfile
#
# the following shows an example of outputting a file with
# the same name as the original but with extension ".xml"
# instead of ".ext"
# comment this line out if you have an OUTFILE defined above
OUTFILE=`echo $file | sed "s/ext$/xml/"`
echo "$CUST" >> $OUTFILE
echo "$INFO1" >> $OUTFILE
# repeat the following as many times as you need
# for INFO3, INFO4 etc
if [ "$INFO2" != "" ]
then
echo "$INFO2" >> $OUTFILE
fi
done
|