[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] sed regular expression driller mig



On 2012-08-10 13:44, Egon Andersen wrote:
 ....
>> Eller også så kan du helt glemme \( og \) ved at bruge dette sed udtryk
>>     "s/..den fejlagtige tekst..//"

 ....
> 
> Jeg stopper med at prøve at få 'sed' til at hjælpe mig med problemet.
> Enten åbner jeg filerne i emacs og retter det manuelt (pyha) eller også skriver jeg et
> mini program til dette specifikke problem.

prøv AWK, gammelt script program der bygger på regular expressions, og er velegnet
til opgaver med "tekst-in" og "tekst-ud".


Den kan i et shell script også kaldes direkte med programmet

men normalt f.eks.:
  awk  -f mitscript.awk    tekst-in.txt  > tekst-ud.txt

du får stadig lidt med escape af special tegn, men idet det nu er en .awk fil
så skal du ikke spekulere på at shell mv. driller med escape/backslash.

Tegnsæt kan du klare ved at gemme dit awkscript som iso-8859-1
brug evt. gedit til at gemme i ønsket tegnsæt.


Dvs. noget i stil med:

/\\(den fejlagtige tekst\\)/ {
   # gør noget med input linje, f.eks. erstat
   gsub(/\\(den fejlagtige tekst\\)/,'korrekt tekst')
   print
   next
}

{  # ikke match, blot print
   print
}




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2012-09-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] *