[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] script der læser en line ad gangen fra fil



On 01/10/2011, at 16.59, Eskild Nielsen wrote:
> Jeg forsøger I bash at lave noget i retning af
> 
> while !EOF do
> læs line fra fil
> copier linie til outputfil (eller std out)
> proces linie og send resultat til outputfil (eller std out)
> done
> 
> linierne indeholder 'grimme ting' som blanktegn, ; : ' og "
> 
> jeg har forsøgt mig med
>   for a in `cat testfil|tr '\n' '\000' |xargs -0 -n1`do; echo $a ; done
> hvor jeg så skulle erstatte echo $a med noget mere spændende - men det virker ikke - den fanger alle de slemme ting i filen,


Hvis du indsætter følgende før din for linie så virker den

OLDIFS=$IFS
IFS="
"
# så bliver linie skift det eneste adskillertegn.

for a in ...

I øvrigt, hvis du bruger $( kommando ) i stedet for ` kommando `så kan du have flere niveauer af nestede kommandoer, altså

$( kommandoniveau1 $(kommandoniveau2 ) )

hvorimod at det ikke virker med flere ` niveauer


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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