#!/bin/bash
#sed -i "s|_1\.dat'|_$1\.dat'|g" ddl.sql
sed -i "s|mt\/1|mt\/$1|g" ddl.sql



date1_1=`head -n 1 /mnt/disk1/data/delete_$1.dat | tail -n 1 | cut -f 1 -d '|'`
date1_2=`head -n 1 /mnt/disk1/data/delete_$1.dat | tail -n 1 | cut -f 2 -d '|'`
sed -i "s|CSW_S_1|$date1_1|g" *.sql
sed -i "s|CSW_E_1|$date1_2|g" *.sql

date2_1=`head -n 2 /mnt/disk1/data/delete_$1.dat | tail -n 1 | cut -f 1 -d '|'`
date2_2=`head -n 2 /mnt/disk1/data/delete_$1.dat | tail -n 1 | cut -f 2 -d '|'`
sed -i "s|CSW_S_2|$date2_1|g" *.sql
sed -i "s|CSW_E_2|$date2_2|g" *.sql

date3_1=`head -n 3 /mnt/disk1/data/delete_$1.dat | tail -n 1 | cut -f 1 -d '|'`
date3_2=`head -n 3 /mnt/disk1/data/delete_$1.dat | tail -n 1 | cut -f 2 -d '|'`
sed -i "s|CSW_S_3|$date3_1|g" *.sql
sed -i "s|CSW_E_3|$date3_2|g" *.sql


date1_1=`head -n 1 /mnt/disk1/data/inventory_delete_$1.dat | tail -n 1 | cut -f 1 -d '|'`
date1_2=`head -n 1 /mnt/disk1/data/inventory_delete_$1.dat | tail -n 1 | cut -f 2 -d '|'`
sed -i "s|INV_S_1|$date1_1|g" *.sql
sed -i "s|INV_E_1|$date1_2|g" *.sql

date2_1=`head -n 2 /mnt/disk1/data/inventory_delete_$1.dat | tail -n 1 | cut -f 1 -d '|'`
date2_2=`head -n 2 /mnt/disk1/data/inventory_delete_$1.dat | tail -n 1 | cut -f 2 -d '|'`
sed -i "s|INV_S_2|$date2_1|g" *.sql
sed -i "s|INV_E_2|$date2_2|g" *.sql

date3_1=`head -n 3 /mnt/disk1/data/inventory_delete_$1.dat | tail -n 1 | cut -f 1 -d '|'`
date3_2=`head -n 3 /mnt/disk1/data/inventory_delete_$1.dat | tail -n 1 | cut -f 2 -d '|'`
sed -i "s|INV_S_3|$date3_1|g" *.sql
sed -i "s|INV_E_3|$date3_2|g" *.sql

