[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:46:15 +0100, Troels Arvin wrote:
> On Fri, 07 Jan 2005 10:24:41 +0100, Klaus S. Madsen wrote:
> 
> > Men fungerer det også hvis du har fil-navne med mellemrum i?
> 
> Ups - det havde jeg glemt at tænke på. Måske indsættelse af nogle
> "-tegn på passende steder kan gøre min førnævnte "kode" mere robust.
Nope... Problemet er at når for-løkken skal splitte outputet fra find
op, benytter den IFS (Internal Field Separator) variablen til at
bestemme hvad der skal splittes efter. Som default er IFS sat til
<tab><space><newline>. Dvs. hvis der er filer med mellemrum i, så går
det galt.

Hvis man så sætter IFS til:

IFS='
'

, 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
:-)

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