![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Variables scope. | dinjo_jo | Shell Programming and Scripting | 13 | 09-10-2008 07:03 AM |
| doubt in arguement variables | rajitha7 | Shell Programming and Scripting | 1 | 05-12-2008 02:56 PM |
| Access Awk Variables Outside Scope | Amruta Pitkar | Shell Programming and Scripting | 7 | 01-15-2008 09:17 AM |
| Access Awk Variables Outside Scope | Amruta Pitkar | UNIX for Advanced & Expert Users | 2 | 10-26-2006 09:35 PM |
| scope | sundaresh | High Level Programming | 7 | 06-28-2006 11:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Doubt??? [scope of variables]
Heres an example.....
[qzv2jm] <~/abc>$ cat textfile line 1 line 2 line 3 line 4 line 5 [qzv2jm] <~/abc>$ cat try.sh #/bin/ksh for runs in 1 2 3 do A=$runs echo "Inside A : $A" done echo "Outside A : $A" <- works fine cat textfile | while read var do echo $var x=$var+1 echo "inside x = $x" done echo "outside x = $x" <- Does not work [qzv2jm] <~/abc>$ try.sh Inside A : 1 Inside A : 2 Inside A : 3 Outside A : 3 <---worked line 1 inside x = line 1+1 line 2 inside x = line 2+1 line 3 inside x = line 3+1 line 4 inside x = line 4+1 line 5 inside x = line 5+1 outside x = <----doubt?? [qzv2jm] <~/abc>$ Question: How can I make 'x' global so that I get the value outside the loop . |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|