[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] test om filer eksisterer i en for loop



On 2008-07-10, Anders Thøgersen <sslug@sslug> wrote:
> Hej,
>
> Hvorfor fungerer dette ikke:
>
> 	foo() { \ls -1 $HOME; }
> 	
> 	for i in $(foo); do
> 	  [[ -e $i ]] && echo $i
> 	done
>
> Jeg forstår det ikke...  Hvis jeg skriver:
>
> 	for i in $(foo); do
> 	  echo $i
> 	done
>
> Så sker der det jeg forventer,.. hmmm, er der nogen der kan hjælpe mig?

Hvor står du henne når du skriver det?

Og hvad er det for noget med [[ ]]?
Og den der \ foran ls ?

Jeg gjorde lige:

foo() { ls -1 $HOME }
for i in $(foo)
do
	[ -e $i ] && echo $i
done

og jeg fik listen af emner der var fælles for pwd og $HOME

Og tilmed virker det hvis /bin/sh ikke nødvendigvis er bash.

/Sune


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2008-08-01, 02:01 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] *