The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Not access variable outside loop when a reading a file ricardo.ludwig Shell Programming and Scripting 4 05-24-2009 12:14 AM
Unable to access 3500 FC array. Where is the problem?.. Sapfeer SUN Solaris 7 04-01-2009 08:03 AM
unable to access a variable not local to a while loop codeman007 Shell Programming and Scripting 6 12-25-2008 04:56 PM
Unable to access home area Mr Pink SUN Solaris 1 04-15-2007 06:57 PM
unable to access hpfs/ntfs properly moxxx68 UNIX for Dummies Questions & Answers 1 11-08-2005 04:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-23-2009
Armaan_S Armaan_S is offline
Registered User
  
 

Join Date: May 2009
Posts: 5
Unable to access variable outside loop

I am unable to access the value set inside the loop from outside loop .
Thought of taking this to forum , I had seen other replies also , where a pipe takes the execution to another shell and mentioned thats the reason we do not get the variable outside loop . But I am getting an issue and I am not using pipe . A sample code below . I do not know where I am going wrong .Any help would be highly appreciated.
(note my tree1.txt contains only 1 line , just trying to test if I can access the value for a variable set inside a while loop)
*************
count=0
while read line
do
count=10
echo $count
done < tree1.lst
echo count:$count
************Result**********
10
count:0
  #2 (permalink)  
Old 05-23-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361

You are using an old Bourne shell (perhaps /bin/sh on Solaris?).

Switch to a standard UNIX shell (/usr/xpg4/bin/sh or ksh).
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0