OVH Cloud OVH Cloud

awk et elisp

2 réponses
Avatar
Ph. Ivaldi
Bonjour,

Sans vouloir abuser de votre patience, que pourrait être l'équivalent
en elisp de la commande suivante:

awk -F: '{ printf ("%s:%s\n",$2,$3) }' fichier.log

Si j'abuse, des pistes devraient me suffire.

Merci.
--
Philippe Ivaldi.

2 réponses

Avatar
lhabert
Ph. Ivaldi :

Sans vouloir abuser de votre patience, que pourrait être l'équivalent
en elisp de la commande suivante:

awk -F: '{ printf ("%s:%sn",$2,$3) }' fichier.log



(while (re-search-forward "^(.*?):(.*?):(.*)$" (point-max) t)
(replace-match "2:3")
)
Avatar
Ph. Ivaldi
Le 10 août 2006 à 16h00:02,
(Luc Habert) écrivit :

Ph. Ivaldi :

Sans vouloir abuser de votre patience, que pourrait être l'équivalent
en elisp de la commande suivante:

awk -F: '{ printf ("%s:%sn",$2,$3) }' fichier.log



(while (re-search-forward "^(.*?):(.*?):(.*)$" (point-max)
t)
(replace-match "2:3")
)



Merci, je n'aurai pas trouvé tout seul.
Le but est de remplacer la commande
(message
(shell-command-to-string
"awk -F: '{ printf ("%s:%sn",$2,$3) }' ficher.log"))

par du code Elisp "pur".

Je procède ainsi:

(defun toto()
(insert-file "fichier.log")
(beginning-of-buffer)
(while (re-search-forward "^(.*?):(.*?):(.*)$" (point-max) t)
(replace-match "2:3"))
(message (buffer-string)))

(with-temp-buffer (toto))

J'ai bon ?
--
Philippe Ivaldi.