Bonjour,
Bon voila un fichier:
Avec la commande:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Jun 13 14:41:33 mtl2100.mtl.globul.fr 22: 1w5d: %SYS-5-CONFIG_I: Configured from console by vty0 (192.168.10.60) Jun 13 14:47:51 mtl3285.mtl.globul.fr 37: 1w0d: %SYS-5-CONFIG_I: Configured from console by vty0 (192.168.10.60) Jun 13 14:48:00 192.168.10.9 23: 1w5d: %SYS-5-CONFIG_I: Configured from console by vty0 (192.168.10.60) Jun 13 14:51:04 192.168.10.9 24: 1w5d: %LINK-5-CHANGED: Interface FastEthernet0/4, changed state to administratively down Jun 13 14:51:04 192.168.10.9 25: 1w5d: %LINK-5-CHANGED: Interface FastEthernet0/5, changed state to administratively down Jun 13 14:51:04 192.168.10.9 26: 1w5d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
J'obtiens ce que je veux:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 cat /dossier/dossier/fichier.txt | cut -f 3,4,9,10,11,12,13,14,15,16,17,18,19,20 -d " "
La question est de savoir s'il y a moins "barbare" comme commande pour obtenir le même résultat. Le but est d'obtenir l'heure, l'auteur (adresse ou mtl...) et le problème, mais il faut faire attention a bien tout selectionné jusqu'à la fin. Le pb étant tout ce qu'il y a jusqu'à la fin de la ligne.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 14:41:33 mtl2100.mtl.globul.fr Configured from console by vty0 (192.168.10.60) 14:47:51 mtl3285.mtl.globul.fr Configured from console by vty0 (192.168.10.60) 14:48:00 192.168.10.9 Configured from console by vty0 (192.168.10.60) 14:51:04 192.168.10.9 Interface FastEthernet0/4, changed state to administratively down [...]
(faudrait vraiment que j'aprenne à utiliser sed ou awk et les expressions régulières...)
Voila, merci
Partager