[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [bash] sætte en variabel i en while-løkke



On Fri, Jan 07, 2005 at 10:20:11 +0100, Troels Arvin wrote:
> On Fri, 07 Jan 2005 09:33:35 +0100, Peter Makholm wrote:
> 
> > Der er et eller andet som sætter et scope, kan jeg komme uden om
> > dette?
> 
> Jeg kan ikke redegøre for bash-variabelscope, men din kode ville jeg
> skrive som følger, og det ser ud til at fungere:
Men fungerer det også hvis du har fil-navne med mellemrum i? Det er
nemlig normalt fordelen ved while read p; løsningen. Men måske kan man
fidle nok med IFS til at løse det?

> bar=foo
> for p in `find . -type f`; do
>   if eval /bin/true; then
>     bar=$p
>   fi
>   echo "bar: $bar"
> done
> echo "value of bar after loop: $bar"

-- 
/-----------------------------------------------------\
| Klaus S. Madsen      | "Ruurgggghhhh urrgh urgh;    |
|                      |  (uh ruh) ruuruuh ug."       |
| www.hjernemadsen.org |   - Douglas Adams, TRATEOTU  |
\-----------------------------------------------------/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *