#!/bin/sh
#
#This is the shell script that when run in the same directory with
#the unzipped whole database files, will create NUT's input
#file "sr27.nut"; header files that describe the data, nut.h, nutrient.h,
#and lookup.h; and the library of serving sizes WEIGHT.lib.
#

rm /tmp/dbjoin* >/dev/null 2>&1
preprocess/dbjoinweight &
[ ! -e /tmp/dbjoin ] && preprocess/dbjoinnuts &
preprocess/dbjoinheaders &
wait
join      -j 1 -t'^' /tmp/dbjoin /tmp/dbjoinweight | sort -r -t^ +2 | tr -d "\r" | sed -e "s/\^0\^/\^\^/g" | sed -e "s/\^0\^/\^\^/g" | sed -e "s/\^0\.0\^/\^\^/g" | sed -e "s/\^0\.0\^/\^\^/g" | sed -e "s/\^0\.00\^/\^\^/g" | sed -e "s/\^0\.00\^/\^\^/g" | sed -e "s/\^0\.000\^/\^\^/g" | sed -e "s/\^0\.000\^/\^\^/g" > raw.data/sr27.nut
rm /tmp/dbjoin* >/dev/null 2>&1
