[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] sed, start af fil navne



Eller en kortere udgave (inspireret af Jacobs svar):

ls | sed 's/-r[0-9]\+$//' | sort -u

Hilsen Johnny :o)

torsdag den 27. Marts 2008 kvad Johnny Ernst Nielsen:
> Så skal du måske kigge på om din afart af sed har særlige
> matchningsregler, for på min maskine virker Jens' forslag nøjagtigt
> som du vil have det.
>
> $ ls
> harry-r100  harry-r2  kurt-r10-r11  sally-r1  sally-r10
>
> $ ls | sed 's/\(.\+\)-r[0-9]\+/\1/' | sort -u
> harry
> kurt-r10
> sally
>
> $ sed --version
> GNU sed version 4.1.5
>
> Hilsen Johnny :o)
>
> torsdag den 27. Marts 2008 kvad Hans Ole Hansen:
> > Tak
> > Men hvad nu hvis filnavnet er kurt-r10-r11, og det jeg ønsker så
> > bliver kurt-r10
> >
> > Dvs kommandoen skal kun slette de sidste tegn her -r11 .
> >
> > "Hans Ole Hansen" <sslug@sslug> skrev i en meddelelse
> > news:sslug@sslug
> >
> > > Jeg har nogle filer sally-r1, sally-r10, harry-r100, harry-r2
> > >
> > > Jeg vil gerne generere en liste hvor de første tegne fra
> > > filnavnet indtil -r[0-9]+ optræder kun engang.
> > > I ovennævnte eksempel skulle listen i såfald blive
> > >
> > > sally
> > > harry
> > >
> > > Hvordan gør jeg det. Jeg tror at jeg skal bruge noget lign
> > >
> > > ls | sed 's/\(.+\)r[0-9]+/\1/' | sort -u
> > >
> > > Men min sed kommando virker ikke som ønsket. Hvad gør jeg galt?



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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