Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Shell Script Question:- can not read variable that was stored from within a while loop when out of the while loop

by sarf13 (Beadle)
on Feb 02, 2012 at 09:05 UTC ( #951386=perlquestion: print w/ replies, xml ) Need Help??
sarf13 has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Shell Script Question:- can not read variable that was stored from within a while loop when out of the while loop
Download Code
Re: Shell Script Question:- can not read variable that was stored from within a while loop when out of the while loop
by Anonymous Monk on Feb 02, 2012 at 09:14 UTC

    See also Where should I post X?, How do I post a question effectively?

    This is PerlMonks. Stay on topic. This is not the place to ask about bugs in your javascript (or the other 'j' language) nor how to learn write a formula in a spreadsheet, even though there are many Monks knowledgeable in such disciplines.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951386]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-07-05 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls