On Fri, Feb 21, 2003 at 10:01:06AM +0100, Pierre Maitre wrote:
> le code AWK en question:
[EMAIL PROTECTED]:~% awk -f /tmp/abcd
awk: /tmp/abcd: line 1: syntax error at or near while
Est-ce qu'il faut que le while se trouve dans un bloc ?
Effectivement, je compl�te le script:
{ truc = "egrep -e '^" VARIABLE "' fichier";
while(system(truc) != 0){}
nom = $12
prenom = $13
date_naissance = $14
rue = $15
NPA = $16
}
et je le lance comme:
awk -f /tmp/abcd -v VARIABLE=truc
et `�a marche' (fichier non trouv� par *egrep*).
Je ne suis pas s�r que cela traite tout, mais probablement une partie
au moins.
En ce qui concerne *ton* code et pourquoi il a fonctionn� et il ne
fonctionne plus, il faudrait comparer les versions de awk:
[EMAIL PROTECTED]:~% ls -la `which awk` `which nawk` `which mawk` `which gawk`
lrwxrwxrwx 1 root root 21 Aug 26 2001 /usr/bin/awk ->
/etc/alternatives/awk
-rwxr-xr-x 1 root root 218232 Jan 17 2002 /usr/bin/gawk
-rwxr-xr-x 1 root root 95004 Jul 18 2001 /usr/bin/mawk
lrwxrwxrwx 1 root root 22 Aug 26 2001 /usr/bin/nawk ->
/etc/alternatives/nawk
[EMAIL PROTECTED]:~% ls -la /etc/alternatives/{awk,nawk,mawk,gawk}
ls: /etc/alternatives/mawk: No such file or directory
ls: /etc/alternatives/gawk: No such file or directory
lrwxrwxrwx 1 root root 13 Jul 26 2002 /etc/alternatives/awk ->
/usr/bin/mawk
lrwxrwxrwx 1 root root 13 Jul 26 2002 /etc/alternatives/nawk ->
/usr/bin/mawk
Donc sur mon syst�me, en ce moment, `awk' appelle `mawk', du package
mawk, au lieu de gawk, package gawk. Il y a peut-�tre aussi des
diff�rences dans les options par d�faut (p.ex. compatibilit� POSIX).
[EMAIL PROTECTED]:/tmp% date | awk -f /tmp/abcd
/bin/sh: fichier: command not found
[EMAIL PROTECTED]:/tmp% date | gawk -f /tmp/abcd
egrep: fichier: No such file or directory
Donc apparemment, les syst�mes que tu as utilis�s r�cemment utilisaient
la version GNU de awk, et non pas `mawk'.
Pour changer pour le syst�me entier, de fa�on � ce que awk soit toujours
gawk:
update-alternatives --config awk
choisir l'option list�e avec gawk.
Pour information:
Mawk is an interpreter for the AWK Programming Language. The AWK
language is useful for manipulation of data files, text retrieval and
processing, and for prototyping and experimenting with algorithms. Mawk
is a new awk meaning it implements the AWK language as defined in Aho,
Kernighan and Weinberger, The AWK Programming Language, Addison-Wesley
Publishing, 1988. (Hereafter referred to as the AWK book.) Mawk conforms
to the Posix 1003.2 (draft 11.3) definition of the AWK language
which contains a few features not described in the AWK book, and mawk
provides a small number of extensions.
.
Mawk is smaller and much faster than gawk. It has some compile-time
limits such as NF = 32767 and sprintf buffer = 1020.
en bref Mawk est compatible POSIX, et peut-�tre que tu as utilis�s
des extensions GNU.
--
http://www-internal.alphanet.ch/linux-leman/ avant de poser
une question. Ouais, pour se d�sabonner aussi.