Sorry All to disturb you again.
May be i m checking wrong. i need somthing like that.
I am using propety file as HandofValidation.property file which contains following data like
--The propety file has some constant which denotes that for EUR region 57 ~ count now from this the script should check whether in count.txt in row number 1 for EUR region ~ count are 57 are not if yes then check next row and so on.....
--Actually now my script gives proper result like in which line has more tilda than first row and gives an error line also .. But my boss want if first line has wrong ~ then my script will fail. So he want to keep all the constants in property file so that that count for perticular region can be take from property file.
--
--Below i am giving how i am using all the files you can give your idea on that.
--HandoffValidation.property
INTELLECT_EUR_DEAL_FLD_COUNT=57
INTELLECT_EUR_CASHFLOW_FLD_COUNT=14
INTELLECT_TOK_DEAL_FLD_COUNT=57
INTELLECT_TOK_CASHFLOW_FLD_COUNT=14
INTELLECT_NY_DEAL_FLD_COUNT=51
INTELLECT_NY_CASHFLOW_FLD_COUNT=14
INTELLECT_CA_DEAL_FLD_COUNT=51
INTELLECT_CA_CASHFLOW_FLD_COUNT=14
-count.txt
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--my script
-new.sh
#!/bin/bash
WORK_DIR=/export/opt/rtrupld/autosys/scripts_old
DATA_DIR=/cdirect/rtrupld/incoming/intellect
#LOG=/export/opt/rtrupld/autosys/logs/impIntEurCshFlw.log
data=`ls $WORK_DIR/count.txt`
propfile=$WORK_DIR/HandoffValidation.properties
awk ' END {print NR}' $data
awk ' { sum=0;
print"::INT:::::",var
print "Total lines",NR
for(i=1; i<= length($0); i++) {if (substr($0,i,1)=="~" ) {sum++} }
if (NR !=1)
{
print "Total lines:::",NR
print "oldsum :::",oldsum
print "sum :::",sum
if (oldsum==sum){
print "oldsum",oldsum
}
else
{
if(oldsum!=sum)
{print "error in ", $data," at line ",NR, " tilde count=",sum}
exit;
} } else{
oldsum=sum
print "oldsum at last",oldsum
}
}' $data
--OPUTPUT
3
::INT:::::
Total lines 1
oldsum at last 52
::INT:::::
Total lines 2
Total lines::: 2
oldsum ::: 52
sum ::: 52
oldsum 52
::INT:::::
Total lines 3
Total lines::: 3
oldsum ::: 52
sum ::: 59
error in OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ at line 3 tilde count= 59
I need output like
above output but it should check variable value.
please suggest on my property file also. whether it is wrong or correct.
--Waiting for your reply.
Thanks & Regards
Ganesh
---------- Post updated at 02:34 PM ---------- Previous update was at 02:15 PM ----------
Hi pravin,
i am gettin following error after using your solution
grep: can't open .properties
awk: syntax error near line 1
awk: bailing out near line 1
--im using like
#!/bin/bash
WORK_DIR=/export/opt/rtrupld/autosys/scripts_old
DATA_DIR=/cdirect/rtrupld/incoming/intellect
#LOG=/export/opt/rtrupld/autosys/logs/impIntEurCshFlw.log
data=`ls $WORK_DIR/count.txt`
propfile=$WORK_DIR/HandoffValidation.properties
awk -v v1=`grep "INTELLECT_EUR_DEAL_FLD_COUNT" $propfile | cut -d"=" -f2` -F'~' '{if (NF-1 != v1) {print "Error in " $0 " at line number "NR " tilde count= " NF-1 }}' $data
---------- Post updated at 03:56 PM ---------- Previous update was at 02:34 PM ----------
[/COLOR]Hi Franklin,
this is not double post of my thread.The reply which i got according to that i replied on that comments.I thought My problem has not getting cleared so i posted in detail what i actually need. in the last thread i explained everything in detail so anybady can understand the proble and give a exact solution.Excuse me if i broke the ruls .Please keep my thread open so i can get correct solution.
Thanks & regards,
Ganesh