Hi,
I have realised that this script will create one output file which is the last entry in the input file. However, I need to create one �utput file for each line. The names of the output file need to include the ID. How can I do this?
Hi,
I have realised that this script will create one output file which is the last entry in the input file. However, I need to create one �utput file for each line. The names of the output file need to include the ID. How can I do this?
See the pattern below.
IFS=;
while read continent country city id address date
do
ID=$id
CONTINENT=$continent
COUNTRY=$country
CITY=$city
DATE=$date
header $ID
body1 $CONTINENT $ID
done < $INPUTFILE
function header {
OUTPUTFILE="$OUTPUTFILE.$1"
echo "$HEADER" > $OUTPUTFILE
echo "$1" >> $OUTPUTFILE
echo "\">" >> $OUTPUTFILE
}
function body1 {
OUTPUTFILE="$OUTPUTFILE.$2"
echo "$1" >>$OUTPUTFILE
echo "$continent" >>$OUTPUTFILE
echo "</info1>" >>$OUTPUTFILE
}
$@ will change to $1 and $2, whereever appropriate.