[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: [TEKNIK] mellemrum i bash



Dit problem er, at $(ls) bliver ekspanderet først, hvorefter den samlede
tekst deles op i ord. Derfor bliver dit filnavn med mellemrum i til to
ord.

En mulig løsning er at bruge

	ls | while read x; do echo $x; done

Det vil læse en linie af gangen, dvs et filnavn, og echo'e den.

Der findes selvfølgelig også den mere effektive version af ovenstående:

	ls

:-)

Thomas Larsen wrote:
> 
> Hej,
> 
> Jeg havde gang i at skrive et shellscript, men er gået i stå ved et problem som jeg efter mange forsøg med alverdens programmer ikke har kunnet finde ud af at omgå.
> Det er i en for-løkke at problemet viser sig.
> 
> for x in $(ls)
> do
>   echo $x
> done
> 
> Hvis filerne indeholer et mellemrum bliver de cuttet i mellemrummet og bliver delt over 2 variable.
> Jeg synes efterhånden at jeg kan man-filen til bash udenad. Hvordan får jeg en variabel til at indeholde en streng med et mellemrum i? Nogen der har nogen erfaringer med den slags?
> 
> /Thomas

-- 
René Seindal (sslug@sslug)			http://www.seindal.dk/rene/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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