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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
i cannot give array declaration in shell script naree SUN Solaris 20 02-19-2008 12:27 AM
double variable declaration kotasateesh Shell Programming and Scripting 3 08-31-2007 02:29 AM
Variable assignment in shell scripting jaiganeshbe Shell Programming and Scripting 2 02-27-2007 11:48 PM
Help with variable declaration dsravan Shell Programming and Scripting 1 12-08-2006 12:15 PM
Variable declaration laila63 High Level Programming 2 07-07-2004 12:37 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-05-2008
Registered User
 

Join Date: Feb 2008
Posts: 1
Global variable declaration in shell scripting

Hi all,

How to print variable value which i have assigned inside for loop
because that variable scope is local, but i want to use that variable outside for loop.

Awaiting your great help

Thanks,
Susil
Reply With Quote
Forum Sponsor
  #2  
Old 02-05-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Code:
[/tmp]$ cat try.sh
#! /bin/sh

for runs in 1 2 3
do
    A=$runs
    echo "Inside loop : $A"
done

echo "Outside loop : $A"
[/tmp]$ ./try.sh
Inside loop : 1
Inside loop : 2
Inside loop : 3
Outside loop : 3
[/tmp]$
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0