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
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 05:28 PM
How to ristrict tar to span multi volume of 1.95 gig each. interim05 AIX 0 06-19-2006 09:36 AM
process Span by shell compbug UNIX for Dummies Questions & Answers 4 06-18-2006 12:43 AM
Will cpio span tapes ? fidodido Shell Programming and Scripting 2 01-11-2006 05: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 08:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
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.
Reply With Quote
Forum Sponsor
  #2  
Old 01-24-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,656
variable not retaining value
Keeping vars set in while loop with redirection
Why doesn't redirecting a loop work as intended? (Bourne shell)
Reply With Quote
  #3  
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.
Reply With Quote
  #4  
Old 01-24-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,656
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.
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 10:18 PM.


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