[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: sammenligne to tekstfiler



Lars Boye Hansen wrote:

> Jeg ønsker at hente filer fra en ftp-server flere gange om dagen. Filerne
> er bzipped og har unik filnavn. For at undgå at hente allerede unzippede
> filer ønsker jeg at gemme filnavnet på en fil efter hver unzipning i et
> txt-dokument (Unzippet.txt). Filnanvnene på ftp-serveren listes løbende i
> et andet txt-dok (RemoteDir.txt). Mit problem består i at:
> 
> 1) sammenligne de to filer og tjekke om filnavn i RemoteDir.txt findes i
> Unzippet.txt; 2) hvis ja gøres ingenting;
> 3) hvis nej hentes filen, den unzippes og filnavnet tilføjes til
> Unzippet.txt.
> 
> Det skal køre i et Bash script, og det kender jeg desværre meget lidt til
> - any suggestions?

Kanske

#!/bin/bash

function Do_It {
  while read Fil ; do
    Grep_Result = $(grep $Fil Unzipped.txt)
    if [[$Grep_Result == 0 ]] ; then # så finns den inte, hämta
      wget fpt.../$Fil
      tar xvjf $Fil
      echo $Fil >> Unzipped.txt
    fi
  done
}

cat RemoteDir.txt | Do_It

Läs Remotedir rad för rad, kolla om filen finns i Unzipped.txt
om inte, hämta,packa upp och lägg till i Unzipped.txt

-- 
/Björn
-------------------------------------------------------------------
http://lundin.homelinux.net
Registered Linux User No. 267342 <http://counter.li.org>


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