[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: expansion af stjerne *



Hans Schou <sslug@sslug> skrev den 29-Apr-04:

> On Thu, 29 Apr 2004, Kristian Nørgaard wrote:

>> > ls *.txt 2>/dev/null | while read FILE ; do echo $FILE ; done

>> Vil du forklare hvorfor din metode er mere effektiv?

> Når du laver en 'for f $(ls -U *.txt)' så vil det give en expansion
> til 2000 filer. Først når den er udpakket, vil for-løkken starte. 

Det er vel også shellen, der ekspanderer *.txt i dit eksempel ovenfor,
så man er lige vidt? Jeg tror at en mere korrekt måde er

 find -name "*.txt" -maxdepth 1 | while read FILE ; do echo "$FILE" ; done

som laver ekspansionen af *.txt løbende, uden først at opbygge en
samlet liste over alle 2000 filer. Og så virker den med filer såsom
"* .txt" på grund af anførselstegnene i slutningen.


Anders.



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 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] *