On 22 May, George Vieira wrote:
>  Simple script problem which I don't know around. 
>   
>  For some reason I can't get any variables inside a do/done loop to be seen 
>  outside the loop..eg. 
>   
>  #!/bin/bash 
>   
>  cat /var/log/blahblah.log | while read a 
>  do 
>          LINE="Hello" 
>          export LINE  <- even this doesn't work...???? 
>          exit 0 
>  done 
>  echo $LINE 
>   
>   
>  LINE returns empty... any ideas why and how around this. I need the th value 
>  outside the loop... 

Because of the pipe, the while is run in a separate shell that's forked
off, so LINE hasn't been set in the parent shell.

You should read the file directly, not via a pipe.

        while read a
        do
        ...
        done < /var/log/blahblah.log
 
luke

--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to