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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-24-2006
Registered User
 

Join Date: Jan 2006
Posts: 8
span of variable

Hi all,
I am having a hard time in determining this. I have a shell script, in which I build a variable in a certain format (-i 'x x.in x.out' -i 'y y.in y.out' -i 'z z.in z.out) within a while loop. But that variable is getting lost if I read it after the while loop is ended. I tried "export".., that did not seem to work either...! please help somebody. thanks.
Sponsored Links
  #2 (permalink)  
Old 01-24-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,150
variable not retaining value
Keeping vars set in while loop with redirection
Why doesn't redirecting a loop work as intended? (Bourne shell)
  #3 (permalink)  
Old 01-24-2006
Registered User
 

Join Date: Jan 2006
Posts: 8
thanks .. , but the way I have my while loop is this...

awk '/^[^#]/ {print $0}' file | while read f1 f2 f3 f3
do
.....
...
build the variable - v
done

read the variable v. (Here v is empty)

i will keep reading the links... in the mean time.
  #4 (permalink)  
Old 01-24-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,150
Um, in case you don't know what a pipe does, proc1 | proc2 forces proc2 to redirect it's input to a pipe which proc1 is writing to. If proc2 is a loop being managed by a bourne shell, it will become a subshell.
Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 08:28 PM
How to ristrict tar to span multi volume of 1.95 gig each. interim05 AIX 0 06-19-2006 01:36 PM
process Span by shell compbug UNIX for Dummies Questions & Answers 4 06-18-2006 04:43 AM
Will cpio span tapes ? fidodido Shell Programming and Scripting 2 01-11-2006 08:42 AM
ksh: A part of variable A's name is inside of variable B, how to update A? pa3be Shell Programming and Scripting 4 03-30-2005 12:29 PM



All times are GMT -4. The time now is 06:39 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0