The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-27-2008
kolesunil kolesunil is offline
Registered User
  
 

Join Date: May 2008
Posts: 8
I have prepared the shell script. Thanks.

Pls see the shell script:


Code:
TestValid()
{
while read -r line
do
echo ${line} | awk -F"|" '{
if (NF == sep_num)
   printf("%s\n", $0) >> fname"_valid_rec";
else
   printf("%s\n", $0) >> fname"_invalid_rec"
}' sep_num="${2}" fname="${1}"
done < ${1}
}

while read -r col1 col2
do
if [ -f ${col1}"_valid_rec" ]; then
  rm ${col1}"_valid_rec"
fi
if [ -f ${col1}"_invalid_rec" ]; then
  rm ${col1}"_invalid_rec"
fi
TestValid ${col1} ${col2}
if [ -f ${col1}"_invalid_rec" ]; then
   mv ${col1} ${col1}"_org"
fi
if [ -f ${col1}"_valid_rec" ]; then
   mv ${col1}"_valid_rec" ${col1}
fi
done < para_new.cfg


Last edited by Yogesh Sawant; 05-27-2008 at 08:09 AM.. Reason: added code tags