[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 ien while-løkke



"Klaus S. Madsen" <sslug@sslug> writes:

> , så den kun indeholder et newline, så splitter for-løkken ikke længere
> efter <space>, men kun efter mellemrum... Så er problemet flyttet til
> hvis man har et filnavn med newline i, men de er ikke nær så almindelige
> :-)

Det er jo bare et spørgsmål om tid. Det indlysende ville være at
bruge:

IFS=$'\0'
for i in $(find -print0) ; do 
  ...
done

Men af næsten lige så indlysende grunde går det heller ikke. Næste
forsøg er at finde et andet deletegn. Lad os vælge et tilfældigt andet
ASCII-kontroltegn, hvad med 0x1C (File Seperator):

IFS=$'\x1C'
for i in $(find -printf $'%p\x1C') ; do
  ...
done

Det virker. Mens jeg godt kunne forestille mig brugere forsøge at lave
filnavne med linjeskift i, så tror jeg ikke de kunne finde på at bruge
mere spøjse kontroltegn.


Tilsyneladende ser dette dog ud til at gemme hele fillisten i
hukommelsen mens jeg mener at en 'find | while' burde kunne nøjes med
at gemme en buffer-fuld ad gangen.

-- 
 Peter Makholm     |               Vi smider blade allesammen - hele tiden
 sslug@sslug |                      som et konstant spirende efterår
 http://hacking.dk |                 Og hele tiden vokser nye frugter frem
                   |                  og vi finder nogen til at plukke dem
                   |                            -- Tilt, Perkussive popler


 
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] *