rm -rf ./Converted/*
for ivar in `ls All_Data/*.txt`;do

#>>>>>> remove blank lines and put EOF <<<<<<
    sed -i '/EOF/d' ${ivar}
    sed -i '/^$/d' ${ivar}
    echo EOF >> ${ivar} 
#>>>>>> get station info <<<<<<#
    vartmp=${ivar%*.txt};   var=${vartmp##*/}
    echo ${var}
    mkdir ./Converted/${var}
    cat ${ivar} |sed /18/d|sed /19/d|sed /20/d|awk '{print $1}' > stainfo.tmp

#>>>>>> 
    for ist in `cat stainfo.tmp`;do
        io=` grep -A 1 -Fx ${ist} stainfo.tmp |tail -1 `
        nline=`sed -n "/\<${ist}\>/,/\<${io}\>/p" ${ivar} | sed /${ist}/d | sed /${io}/d |wc -l`
        echo $ist $nline > ./Converted/${var}/${var}_${ist}.txt
        sed -n "/\<${ist}\>/,/\<${io}\>/p" ${ivar} | sed /${ist}/d | sed /${io}/d >> ./Converted/${var}/${var}_${ist}.txt        
        rm -rf ./Converted/${var}/*EOF*
    done
#    rm -rf stainfo.tmp
done
