[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] Sletning af filer ud fra liste



On 23/06/13 11:28, Thue Janus Kristensen wrote:
Hvis din fil indeholder regexps så som

^filnavn$

Der er ingen regexps i filen. Der er ét filnavn pr. linie, så hver linie svarer til én fil der ikke skal slettes.

Filnavnene kan se sådan ud som nedenstående:
20130622_165534_00.jpg
20130622_165534_01.cr2

så kan du gøre følgende

ls --color=never|grep -v -f patterns |xargs --delimiter "\n" rm

Ville
ls --color=never -A1 | grep -v -f patterns |xargs --delimiter "\n" rm
ikke være bedre? Det vil begrænse sig til ét navn pr linie, som input til resten. Umiddelbart ville jeg tro at ovenstående ville slette alle filer på én linie (i output fra ls), bare ét af dem ikke matcher noget i filen. Tager jeg fejl i det?

Jeg går ud fra at 'patterns' er navnet på den fil der indeholder de filnavne der ikke skal slettes. Er det korrekt?

Så hvis dine filer bare indeholde[a-zA-Z_0-9.], så kan du bare sætter ^$
ind i filen (med sed eller en emacs-makro fx), så bør det virke.

Sætte ^$ ind i filen hvor?

Det er noget der på sigt helst skal kunne automatiseres, så jo mindre filen med filnavnene skal ændres, jo bedre.

Bemærk at med grep's regexps-syntax, så er "." bare ".", mens "\." er en
vilkårlig karakter.

Tak for tippet, men jeg skal i dette tilfælde ikke bruge regexps. :-)

--

        |\     _,,,---,,_       Greetings, Jens
 ZZZzz /,`.-'`'    -.  ;-;;,_
      |,4-  ) )-,_. ,\ (  `'-'  sslug@sslug
     '---''(_/--'  `-'\_)
----------------------------------------------------
There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
                                                  -- Jeremy S. Anderson


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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