tag=0 for file in Directory_PATH/* do stat_file=`grep "#ST#" $file|cut -d"," -f4` echo "#####$stat_file==" #cat tempimp1|grep "^HS.*"|while read line1 while read line1 do hsval=`grep "^HS."` echo "========$hsval----" if [ "$stat_file" == "$hsval" ] then val=`grep "1001,Duplicate FORE" $file` echo "===sarfaraz" if [ "$val" == " " ] then echo "SUCCESS" #tag=127 else echo "yamamama" tag=127 echo "$tag###########" fi else echo "FILE IS NOT MATCHING " fi done < tempimp1 exit done rm -f tempimp1 echo "------$tag#####" if [ "$tag" == "127" ] then echo "FAILED" exit 127 else echo "FINAL SUCCESS"
In this code i am trying to read multiple file from a directory, grep some value from it. there is another file named "tempimp1" which having two value
1)-HS.SCMC.20120130.CR.1
2)-HS.SCMC.20120130.NW.1
this value should match "if "$stat_file" == "$hsval" "
in this scetion i need to match this value. once it match i need to assign tag value. i want to use this assign value outside the while loop.
I Really appriciate for your kind support
In reply to Shell Script Question:- can not read variable that was stored from within a while loop when out of the while loop by sarf13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |