#!/bin/bash rm outSeg.tmp thisPath=$PWD netPath=//ustca239.kcc.com/JoesHop/RiverbedExports/ pushd $netPath ls *.csv | while read theFile do tmp=${theFile#*-} date=${tmp:0:10} funct=${theFile%%-*} echo $theFile - $date - $funct awk -F , -e 'FNR > 1 {print "'${date}',"$2","$3",'${funct}',"$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15","$16 }' $theFile >> "${thisPath}/outSeg.tmp" mv ${netPath}$theFile "${thisPath}/archive/" 2> /dev/null done popd cat outSeg.tmp >> PerfData.csv