Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3584 connectés 

  FORUM HardWare.fr
  Programmation
  Shell/Batch

  Différences entre gawk et les autres awk

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Différences entre gawk et les autres awk

n°1885390
stagebi
Posté le 17-05-2009 à 15:23:04  profilanswer
 

Bonjour,
J'ai un script écrit pour gawk qui fonctionne très bien mais lorsque que je veux l'exécuter sur une machine (AIX-IBM) ayant uniquement awk (ou mwak) le script ne fonctionne plus.
Vous avez une idée des adaptations a faire pour le rendre compatible?
Je ne trouve pas les différences entre les différentes "version" d'AWK
 
Le script :  
 

Code :
  1. function parseCreate(t) {
  2.    match(t, /^CREATE TABLE : ([^;[:space:]]+);([^[:space:]]+) AS$/, a)
  3.    if ( 2 in a ) {
  4.       Program = a[1]
  5.       Table = a[2]
  6.    }
  7. }
  8. function parseSelect(t) {
  9.    match(t, /^SELECT : ([^;[:space:]]+);([^[:space:]]+)$/, a)
  10.    if ( 2 in a ) {
  11.       if ( a[1] == Program ) {
  12.      delete Select
  13.          split(a[2], Select, "," )
  14.       }
  15.    }
  16. }
  17. function parseFrom(t) {
  18.    match(t, /^FROM : ([^;[:space:]]+);([^;]+)$/, a)
  19.    if ( 2 in a ) {
  20.       if ( a[1] == Program ) {
  21.      split(a[2], b, "," )
  22.          delete From
  23.          for ( n in b ) {
  24.             match(b[n], /([^[:space:]]+) ([^[:space:]]+)/, a)
  25.             if (2 in a) {
  26.                From[a[2]] = a[1]
  27.             } else {
  28.                From[0] = b[n]
  29.             }
  30.          }
  31.       }
  32.    }
  33. }
  34.  
  35. BEGIN {
  36.    Program = "MISSING"
  37. }
  38.  
  39. /^CREATE/ { parseCreate($0) }
  40. Program != "MISSING" {
  41.    if ($0 ~ /^SELECT/) {
  42.       parseSelect($0)
  43.    }
  44.    if ($0 ~ /^FROM/) {
  45.       parseFrom($0)
  46.       for (n in Select) {
  47.          match(Select[n], /([^.]+)\.([^.]+)/, a)
  48.          if ( 2 in a ) {
  49.             print Program,";",Table,";",From[a[1]],";",a[2]
  50.          } else {
  51.             print Program,";",Table,";",From[0],";",Select[n]
  52.          }
  53.       }
  54.       Program = "MISSING"
  55.    }
  56. }


 
Merci d'avance

mood
Publicité
Posté le 17-05-2009 à 15:23:04  profilanswer
 

n°1885396
masklinn
í dag viðrar vel til loftárása
Posté le 17-05-2009 à 15:47:53  profilanswer
 

Tout est dans le manuel officiel de gawk [:spamafote]

 

http://www.gnu.org/manual/gawk/htm [...] IX_002fGNU
http://www.gnu.org/manual/gawk/htm [...] Extensions


Message édité par masklinn le 17-05-2009 à 15:49:56

---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1885761
stagebi
Posté le 18-05-2009 à 16:27:09  profilanswer
 

Oui merci, donc apparement c'est essentiellement la fonction match qui n'est présente que dans gawk.
Vous voyez comment faire pour la remplacer?

n°1885789
stagebi
Posté le 18-05-2009 à 17:21:32  profilanswer
 

En faite je ne sais pas lire...
La fonction est match existe bien mais pas le 3ème paramètre (optionnel) dont je me sert dans le script...


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Shell/Batch

  Différences entre gawk et les autres awk

 

Sujets relatifs
Listing des différences avec le C++Différences de perfs entre foreach et array_map
[resolu]différences entre deux fichiersDifférences à la compilation
compter le nombre de différences de deux fichiers (diff...)comparer 2 colonnes et identifier les différences
Gawk : quote refusé sous WindowsDemande d'aide pour utilisation gawk
IE/Firefox - C'est normal toutes ces différences, là ? 
Plus de sujets relatifs à : Différences entre gawk et les autres awk


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)