Exraire les donnes d'un fichier
Résolu/Fermé
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
-
9 avril 2012 à 12:43
othmane19 Messages postés 96 Date d'inscription jeudi 16 avril 2009 Statut Membre Dernière intervention 27 avril 2013 - 11 avril 2012 à 18:15
othmane19 Messages postés 96 Date d'inscription jeudi 16 avril 2009 Statut Membre Dernière intervention 27 avril 2013 - 11 avril 2012 à 18:15
A voir également:
- Exraire les donnes d'un fichier
- Fichier rar - Guide
- Fichier host - Guide
- Téléchargez cette archive (dossier compressé). en extraire tous les fichiers dans un dossier local. quel fichier contient l’expression trouverpix ? ✓ - Forum Windows
- Fichier iso - Guide
- Comment réduire la taille d'un fichier - Guide
39 réponses
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
10 avril 2012 à 15:28
10 avril 2012 à 15:28
on peut pas intégrer le paramètre nom fichier (tg) dans la boucle au lieu de le rentrer et d'orienter chaque fois la ligne dans un fichier finale
merci d'avance
merci d'avance
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
10 avril 2012 à 15:32
10 avril 2012 à 15:32
je viens de tester ca
open(FP,'<','tg');
while (<FP>) {
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ; if($c4 > 10){print $_}
}
il marche mais je cherche a orienter les lignes vers d'autre fichier
et merci d'avance
open(FP,'<','tg');
while (<FP>) {
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ; if($c4 > 10){print $_}
}
il marche mais je cherche a orienter les lignes vers d'autre fichier
et merci d'avance
dubcek
Messages postés
18589
Date d'inscription
lundi 15 janvier 2007
Statut
Contributeur
Dernière intervention
21 mars 2023
5 584
10 avril 2012 à 15:34
10 avril 2012 à 15:34
$ cat p1
open (STDIN, "< tg");
while (<>) {
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ; if($c4 > 10){print $_}
}
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
10 avril 2012 à 15:40
10 avril 2012 à 15:40
reste a rediriger l'affichage vers un autre fichier et c'est fini
merci d'avance
merci d'avance
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
10 avril 2012 à 15:47
10 avril 2012 à 15:47
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
10 avril 2012 à 15:55
10 avril 2012 à 15:55
mais s marche pas quand j'ajoute ca:>
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ; if($c4 >$a ){print $_}>test;
merci d'avance
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ; if($c4 >$a ){print $_}>test;
merci d'avance
dubcek
Messages postés
18589
Date d'inscription
lundi 15 janvier 2007
Statut
Contributeur
Dernière intervention
21 mars 2023
5 584
10 avril 2012 à 16:25
10 avril 2012 à 16:25
soit
perl script > logsoit
open (LOG, ">log");
open (STDIN, "< tg");
while (<>) {
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ; if($c4 > 10){print LOG $_}
}
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
10 avril 2012 à 17:25
10 avril 2012 à 17:25
je te remercie
sans toi ca aurait été difficile
merci
sans toi ca aurait été difficile
merci
mamiemando
Messages postés
32298
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
23 mars 2023
7 575
11 avril 2012 à 00:18
11 avril 2012 à 00:18
Au passage si tu peux ouvrir un nouveau sujet pour chaque nouvelle question... ce serait cool :-)
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 09:29
11 avril 2012 à 09:29
Bonjour;
serait il d'avoir des explications sur cette ligne:
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ;
par ce que j'aurai besoin de faire d'autre extraction
en fait je voulais extraire les adresse mac dont leur state et free en passant par script Perl
voila un exemple de fichier
merci d'avance de votre aide
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
serait il d'avoir des explications sur cette ligne:
($c1,$c2,$c3,$c4)=split(/\+/); $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ ;
par ce que j'aurai besoin de faire d'autre extraction
en fait je voulais extraire les adresse mac dont leur state et free en passant par script Perl
voila un exemple de fichier
merci d'avance de votre aide
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
dubcek
Messages postés
18589
Date d'inscription
lundi 15 janvier 2007
Statut
Contributeur
Dernière intervention
21 mars 2023
5 584
11 avril 2012 à 14:10
11 avril 2012 à 14:10
serait il d'avoir des explications sur cette ligne:
($c1,$c2,$c3,$c4)=split(/\+/) on stocke les 4 premiers champs séparés par + dans des variables c1, c2 ... $c4 =~s/(^[\d]+\.[\d]+).*$/\1/ on modifie c4 en ne gardant que : [chiffres] point [chifres], donc de 10.11.12, on ne garde que 10.11
mamiemando
Messages postés
32298
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
23 mars 2023
7 575
11 avril 2012 à 09:57
11 avril 2012 à 09:57
L'idéal ce serait que tu regardes un cours sur les expressions régulières ou sur sed :
https://fr.wikipedia.org/wiki/Expression_rationnelle
https://fr.wikipedia.org/wiki/Stream_Editor
- split : sépare une chaîne en un tableau ou chaque cellule est délimitée par un caractère (ici +). Le + est précédé d'un \ car c'est un meta-caractère des expressions régulières
- (^[\d]+\.[\d]+).*$
^: commence par
\d : un entier
[\d]+: un entier répété entre 1 et une infinité de fois
\. : le caractère "." (car "." est aussi un meta-caractère des expressions régulières)
[\d]+\.[\d]+ : décrit dont une valeur flottante (dans ton cas ce sont en fait les deux premiers nombres d'une ipv4)
([\d]+\.[\d]+) : les parenthèses ici permettent de dire qu'on va extraire dans une variable temporaire. Cette variable sera désignée par \1. Dans l'absolu on peut extraire plusieurs morceaux qui seront respectivement désignés \1, \2 etc...
- . : n'importe quel caractère
- .* : une répétition entre 0 et une infinité de fois
- $ : fini par (on voit donc que .*$ est probablement superflu)
s/motif/substition : remplace la première occurrence de motif par substitution : ici la substitition correspond à la variable \1 (donc le flottant que tu as extrait). Ceci revient donc à écrire le morceau que tu as extrait (par exemple 11.22), mais si on avait mis >\1< par exemple, ça aurait consisté à la réécrire encadrée des caractères >...< (ici >11.22<).
Bonne chance
https://fr.wikipedia.org/wiki/Expression_rationnelle
https://fr.wikipedia.org/wiki/Stream_Editor
- split : sépare une chaîne en un tableau ou chaque cellule est délimitée par un caractère (ici +). Le + est précédé d'un \ car c'est un meta-caractère des expressions régulières
- (^[\d]+\.[\d]+).*$
^: commence par
\d : un entier
[\d]+: un entier répété entre 1 et une infinité de fois
\. : le caractère "." (car "." est aussi un meta-caractère des expressions régulières)
[\d]+\.[\d]+ : décrit dont une valeur flottante (dans ton cas ce sont en fait les deux premiers nombres d'une ipv4)
([\d]+\.[\d]+) : les parenthèses ici permettent de dire qu'on va extraire dans une variable temporaire. Cette variable sera désignée par \1. Dans l'absolu on peut extraire plusieurs morceaux qui seront respectivement désignés \1, \2 etc...
- . : n'importe quel caractère
- .* : une répétition entre 0 et une infinité de fois
- $ : fini par (on voit donc que .*$ est probablement superflu)
s/motif/substition : remplace la première occurrence de motif par substitution : ici la substitition correspond à la variable \1 (donc le flottant que tu as extrait). Ceci revient donc à écrire le morceau que tu as extrait (par exemple 11.22), mais si on avait mis >\1< par exemple, ça aurait consisté à la réécrire encadrée des caractères >...< (ici >11.22<).
Bonne chance
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 10:01
11 avril 2012 à 10:01
Salut mamie,
Sans compter que la solution lui a été donnée là par dubcek avec "awk", et juste au-dessus pour "sed" ;-\
Et je ne parle même pas de ça ;-(
Sans compter que la solution lui a été donnée là par dubcek avec "awk", et juste au-dessus pour "sed" ;-\
Et je ne parle même pas de ça ;-(
mamiemando
Messages postés
32298
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
23 mars 2023
7 575
11 avril 2012 à 10:04
11 avril 2012 à 10:04
Oui je suis d'accord avec toi, othmane19 pourrait s'investir un petit peu plus...
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 10:09
11 avril 2012 à 10:09
merci pour vos réponse
justement j'étais entrain de tester avec les solutions proposé mais je vois que cette commande ne marche pas avec le fichier que j'ai.
je pense qu'il faut adapter la commande sed mais j'ai du mal avec cette commande
merci d'avance
sed -n '/^binding state free/{:z;n;/^hardware/! bz;p}' f
voila le fichier l'exemple du fichier :
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
justement j'étais entrain de tester avec les solutions proposé mais je vois que cette commande ne marche pas avec le fichier que j'ai.
je pense qu'il faut adapter la commande sed mais j'ai du mal avec cette commande
merci d'avance
sed -n '/^binding state free/{:z;n;/^hardware/! bz;p}' f
voila le fichier l'exemple du fichier :
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 10:13
11 avril 2012 à 10:13
Si si, la commande marche très bien :
Et à la limite, on peut faire comme ceci aussi :
$ sed -n '/^binding state free/{:z;n;/^hardware/! bz;p}' fic
hardware ethernet 00:20:d2:25:54:23;
hardware ethernet 00:14:22:c3:38:53;
Et à la limite, on peut faire comme ceci aussi :
$ sed -n '/^binding state free/,/^hardware/{/binding state free/b;/hardware/p}' fic
hardware ethernet 00:20:d2:25:54:23;
hardware ethernet 00:14:22:c3:38:53;
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 10:24
11 avril 2012 à 10:24
merci pour ta réponse mais je vous assure qu'avec ce fichier la:il affiche rien .
merci d'avance
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
merci d'avance
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 11:11
11 avril 2012 à 11:11
Affiche la sortie de :
cat -A ton_fichier
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 11:27
11 avril 2012 à 11:27
merci pour ta réponse
voila le fichier c'est un peu long vu que c'est un fichier log mais ca tourne toujours sur le même principe
par contre ca marche avec d'autre fichier et d'autre ca marche pas
merci d'avance de ton aide
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.1.3
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1b;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1d;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1f;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:37:14;
ends 3 2012/04/04 14:38:26;
cltt 3 2012/04/04 14:37:14;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:37:50;
ends 3 2012/04/04 14:39:02;
cltt 3 2012/04/04 14:37:50;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:38:26;
ends 3 2012/04/04 14:39:38;
cltt 3 2012/04/04 14:38:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:39:02;
ends 3 2012/04/04 14:40:14;
cltt 3 2012/04/04 14:39:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:39:38;
ends 3 2012/04/04 14:40:50;
cltt 3 2012/04/04 14:39:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:40:14;
ends 3 2012/04/04 14:41:26;
cltt 3 2012/04/04 14:40:14;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:40:50;
ends 3 2012/04/04 14:42:02;
cltt 3 2012/04/04 14:40:50;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:41:26;
ends 3 2012/04/04 14:42:38;
cltt 3 2012/04/04 14:41:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:42:02;
ends 3 2012/04/04 14:43:14;
cltt 3 2012/04/04 14:42:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:42:38;
ends 3 2012/04/04 14:43:50;
cltt 3 2012/04/04 14:42:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:43:14;
ends 3 2012/04/04 14:44:26;
cltt 3 2012/04/04 14:43:14;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:43:50;
ends 3 2012/04/04 14:45:02;
cltt 3 2012/04/04 14:43:50;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:44:26;
ends 3 2012/04/04 14:45:38;
cltt 3 2012/04/04 14:44:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:45:02;
ends 3 2012/04/04 14:46:14;
cltt 3 2012/04/04 14:45:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
voila le fichier c'est un peu long vu que c'est un fichier log mais ca tourne toujours sur le même principe
par contre ca marche avec d'autre fichier et d'autre ca marche pas
merci d'avance de ton aide
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.1.3
lease 192.168.100.10 {
starts 3 2012/03/28 08:01:45;
ends 3 2012/03/28 08:11:45;
tstp 3 2012/03/28 08:11:45;
cltt 3 2012/03/28 08:01:45;
binding state free;
hardware ethernet 00:20:d2:25:54:23;
}
lease 192.168.100.2 {
starts 1 2012/04/02 09:54:36;
ends 1 2012/04/02 09:55:48;
tstp 1 2012/04/02 09:55:48;
cltt 1 2012/04/02 09:54:36;
binding state free;
hardware ethernet 00:14:22:c3:38:53;
uid "\001\000\024\"\3038S";
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:35:26;
ends 3 2012/04/04 14:36:38;
cltt 3 2012/04/04 14:35:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1b;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:02;
ends 3 2012/04/04 14:37:14;
cltt 3 2012/04/04 14:36:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1d;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:36:38;
ends 3 2012/04/04 14:37:50;
cltt 3 2012/04/04 14:36:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1f;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:37:14;
ends 3 2012/04/04 14:38:26;
cltt 3 2012/04/04 14:37:14;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:37:50;
ends 3 2012/04/04 14:39:02;
cltt 3 2012/04/04 14:37:50;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:38:26;
ends 3 2012/04/04 14:39:38;
cltt 3 2012/04/04 14:38:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:39:02;
ends 3 2012/04/04 14:40:14;
cltt 3 2012/04/04 14:39:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:39:38;
ends 3 2012/04/04 14:40:50;
cltt 3 2012/04/04 14:39:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:40:14;
ends 3 2012/04/04 14:41:26;
cltt 3 2012/04/04 14:40:14;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:40:50;
ends 3 2012/04/04 14:42:02;
cltt 3 2012/04/04 14:40:50;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:41:26;
ends 3 2012/04/04 14:42:38;
cltt 3 2012/04/04 14:41:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:42:02;
ends 3 2012/04/04 14:43:14;
cltt 3 2012/04/04 14:42:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:42:38;
ends 3 2012/04/04 14:43:50;
cltt 3 2012/04/04 14:42:38;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:43:14;
ends 3 2012/04/04 14:44:26;
cltt 3 2012/04/04 14:43:14;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:43:50;
ends 3 2012/04/04 14:45:02;
cltt 3 2012/04/04 14:43:50;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:44:26;
ends 3 2012/04/04 14:45:38;
cltt 3 2012/04/04 14:44:26;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
lease 192.168.100.14 {
starts 3 2012/04/04 14:45:02;
ends 3 2012/04/04 14:46:14;
cltt 3 2012/04/04 14:45:02;
binding state active;
next binding state free;
hardware ethernet 00:20:d2:2b:f6:1a;
}
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 11:29
11 avril 2012 à 11:29
Ça ce n'est pas ce que je t'ai demandé ;-(
Merci de relire le message précédent et d'afficher le résultat de la commande demandée !
Merci de relire le message précédent et d'afficher le résultat de la commande demandée !
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 11:48
11 avril 2012 à 11:48
Ok je vois
voila le cat -A
merci d'avance
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
binding state free;$
next binding state free;$
hardware ethernet 44:20:d2:2b:f6:1a;$
$
$
$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
$
binding state free;$
next binding state free;$
hardware ethernet 45:20:d2:2b:f6:1a;$
$
$
$
lease 192.168.100.10 {$
starts 3 2012/03/28 08:01:45;$
ends 3 2012/03/28 08:11:45;$
binding state free;$
next binding state free;$
hardware ethernet 00:20:d2:25:54:23;$
}$
$
lease 192.168.100.2 {$
starts 1 2012/04/02 09:54:36;$
ends 1 2012/04/02 09:55:48;$
$
$
binding state free;$
hardware ethernet 00:14:22:c3:38:53;$
uid "\001\000\024\"\3038S";$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:35:26;$
ends 3 2012/04/04 14:36:38;$
$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
cltt 3 2012/04/04 14:36:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
$
root@BABALLE-01:~# sed -n '/^binding state free/,/^hardware/{/binding state free/b;/hardware/p}' f4
root@BABALLE-01:~# cat -A f4
# The format of this file is documented in the dhcpd.leases(5) manual page.$
# This lease file was written by isc-dhcp-V3.1.3$
$
lease 192.168.100.10 {$
starts 3 2012/03/28 08:01:45;$
ends 3 2012/03/28 08:11:45;$
tstp 3 2012/03/28 08:11:45;$
cltt 3 2012/03/28 08:01:45;$
binding state free;$
hardware ethernet 00:20:d2:25:54:23;$
}$
lease 192.168.100.2 {$
starts 1 2012/04/02 09:54:36;$
ends 1 2012/04/02 09:55:48;$
tstp 1 2012/04/02 09:55:48;$
cltt 1 2012/04/02 09:54:36;$
binding state free;$
hardware ethernet 00:14:22:c3:38:53;$
uid "\001\000\024\"\3038S";$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:35:26;$
ends 3 2012/04/04 14:36:38;$
cltt 3 2012/04/04 14:35:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1b;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
cltt 3 2012/04/04 14:36:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1d;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:38;$
ends 3 2012/04/04 14:37:50;$
cltt 3 2012/04/04 14:36:38;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1f;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:37:14;$
ends 3 2012/04/04 14:38:26;$
cltt 3 2012/04/04 14:37:14;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:37:50;$
ends 3 2012/04/04 14:39:02;$
cltt 3 2012/04/04 14:37:50;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:38:26;$
ends 3 2012/04/04 14:39:38;$
cltt 3 2012/04/04 14:38:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:39:02;$
ends 3 2012/04/04 14:40:14;$
cltt 3 2012/04/04 14:39:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:39:38;$
ends 3 2012/04/04 14:40:50;$
cltt 3 2012/04/04 14:39:38;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:40:14;$
ends 3 2012/04/04 14:41:26;$
cltt 3 2012/04/04 14:40:14;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:40:50;$
ends 3 2012/04/04 14:42:02;$
cltt 3 2012/04/04 14:40:50;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:41:26;$
ends 3 2012/04/04 14:42:38;$
cltt 3 2012/04/04 14:41:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:42:02;$
ends 3 2012/04/04 14:43:14;$
cltt 3 2012/04/04 14:42:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:42:38;$
ends 3 2012/04/04 14:43:50;$
cltt 3 2012/04/04 14:42:38;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:43:14;$
ends 3 2012/04/04 14:44:26;$
cltt 3 2012/04/04 14:43:14;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:43:50;$
ends 3 2012/04/04 14:45:02;$
cltt 3 2012/04/04 14:43:50;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:44:26;$
ends 3 2012/04/04 14:45:38;$
cltt 3 2012/04/04 14:44:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:45:02;$
ends 3 2012/04/04 14:46:14;$
cltt 3 2012/04/04 14:45:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
$
$
voila le cat -A
merci d'avance
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
binding state free;$
next binding state free;$
hardware ethernet 44:20:d2:2b:f6:1a;$
$
$
$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
$
binding state free;$
next binding state free;$
hardware ethernet 45:20:d2:2b:f6:1a;$
$
$
$
lease 192.168.100.10 {$
starts 3 2012/03/28 08:01:45;$
ends 3 2012/03/28 08:11:45;$
binding state free;$
next binding state free;$
hardware ethernet 00:20:d2:25:54:23;$
}$
$
lease 192.168.100.2 {$
starts 1 2012/04/02 09:54:36;$
ends 1 2012/04/02 09:55:48;$
$
$
binding state free;$
hardware ethernet 00:14:22:c3:38:53;$
uid "\001\000\024\"\3038S";$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:35:26;$
ends 3 2012/04/04 14:36:38;$
$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
cltt 3 2012/04/04 14:36:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
$
root@BABALLE-01:~# sed -n '/^binding state free/,/^hardware/{/binding state free/b;/hardware/p}' f4
root@BABALLE-01:~# cat -A f4
# The format of this file is documented in the dhcpd.leases(5) manual page.$
# This lease file was written by isc-dhcp-V3.1.3$
$
lease 192.168.100.10 {$
starts 3 2012/03/28 08:01:45;$
ends 3 2012/03/28 08:11:45;$
tstp 3 2012/03/28 08:11:45;$
cltt 3 2012/03/28 08:01:45;$
binding state free;$
hardware ethernet 00:20:d2:25:54:23;$
}$
lease 192.168.100.2 {$
starts 1 2012/04/02 09:54:36;$
ends 1 2012/04/02 09:55:48;$
tstp 1 2012/04/02 09:55:48;$
cltt 1 2012/04/02 09:54:36;$
binding state free;$
hardware ethernet 00:14:22:c3:38:53;$
uid "\001\000\024\"\3038S";$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:35:26;$
ends 3 2012/04/04 14:36:38;$
cltt 3 2012/04/04 14:35:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1b;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:02;$
ends 3 2012/04/04 14:37:14;$
cltt 3 2012/04/04 14:36:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1d;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:36:38;$
ends 3 2012/04/04 14:37:50;$
cltt 3 2012/04/04 14:36:38;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1f;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:37:14;$
ends 3 2012/04/04 14:38:26;$
cltt 3 2012/04/04 14:37:14;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:37:50;$
ends 3 2012/04/04 14:39:02;$
cltt 3 2012/04/04 14:37:50;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:38:26;$
ends 3 2012/04/04 14:39:38;$
cltt 3 2012/04/04 14:38:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:39:02;$
ends 3 2012/04/04 14:40:14;$
cltt 3 2012/04/04 14:39:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:39:38;$
ends 3 2012/04/04 14:40:50;$
cltt 3 2012/04/04 14:39:38;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:40:14;$
ends 3 2012/04/04 14:41:26;$
cltt 3 2012/04/04 14:40:14;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:40:50;$
ends 3 2012/04/04 14:42:02;$
cltt 3 2012/04/04 14:40:50;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:41:26;$
ends 3 2012/04/04 14:42:38;$
cltt 3 2012/04/04 14:41:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:42:02;$
ends 3 2012/04/04 14:43:14;$
cltt 3 2012/04/04 14:42:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:42:38;$
ends 3 2012/04/04 14:43:50;$
cltt 3 2012/04/04 14:42:38;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:43:14;$
ends 3 2012/04/04 14:44:26;$
cltt 3 2012/04/04 14:43:14;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:43:50;$
ends 3 2012/04/04 14:45:02;$
cltt 3 2012/04/04 14:43:50;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:44:26;$
ends 3 2012/04/04 14:45:38;$
cltt 3 2012/04/04 14:44:26;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
lease 192.168.100.14 {$
starts 3 2012/04/04 14:45:02;$
ends 3 2012/04/04 14:46:14;$
cltt 3 2012/04/04 14:45:02;$
binding state active;$
next binding state free;$
hardware ethernet 00:20:d2:2b:f6:1a;$
}$
$
$
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 11:53
11 avril 2012 à 11:53
Ben je viens de refaire un test avec ton fichier et chez moi le résultat est toujours bon :
Sur quel système es-tu ?
Si GNU/Linux, quelle distrib ?
Quelle version de "sed" (sed --version) ?
$ sed -n '/^binding state free/,/^hardware/{/binding state free/b;/hardware/p}' fich
hardware ethernet 00:20:d2:25:54:23;
hardware ethernet 00:14:22:c3:38:53;
Sur quel système es-tu ?
Si GNU/Linux, quelle distrib ?
Quelle version de "sed" (sed --version) ?
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 12:05
11 avril 2012 à 12:05
c'est pas possible je sais pas c'est quoi le probleme
voila les infos mais je pense pas que ca vient de la
d'ailleurs je sais pas est ce que un script perl peux supporter une commande sed si nom je sais pas est ce qu'il aura une alternative en perl (script perl)
merci d'avance
version linux
2.6.32-37-server #81-Ubuntu SMP Fri Dec 2 20:49:12 UTC 2011 x86_64 GNU/Linux
version sed
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-utils@gnu.org>.
Be sure to include the word ''sed'' somewhere in the ''Subject:'' field.
voila les infos mais je pense pas que ca vient de la
d'ailleurs je sais pas est ce que un script perl peux supporter une commande sed si nom je sais pas est ce qu'il aura une alternative en perl (script perl)
merci d'avance
version linux
2.6.32-37-server #81-Ubuntu SMP Fri Dec 2 20:49:12 UTC 2011 x86_64 GNU/Linux
version sed
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-utils@gnu.org>.
Be sure to include the word ''sed'' somewhere in the ''Subject:'' field.
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 12:13
11 avril 2012 à 12:13
Bizarre tout ça :-\
Est-ce que cette simple commande te retourne quelque chose ???
Pour Perl il faudrait adapter la commande "sed", par contre n'y connaissant rien en Perl, je ne pourrai t'être d'un grand secours ;-(
Est-ce que cette simple commande te retourne quelque chose ???
$ sed -n '/^binding state free/p' f4 binding state free; binding state free;
Pour Perl il faudrait adapter la commande "sed", par contre n'y connaissant rien en Perl, je ne pourrai t'être d'un grand secours ;-(
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 12:12
11 avril 2012 à 12:12
avec une fichier(nomé h) qui contient:
root@BABALLE-01:~# cat -A h
lease 192.168.100.10 {$
starts 3 2012/03/28 08:01:45;$
ends 3 2012/03/28 08:11:45;$
tstp 3 2012/03/28 08:11:45;$
cltt 3 2012/03/28 08:01:45;$
binding state free;$
hardware ethernet 22:20:d2:25:54:23;$
}$
lease 192.168.100.2 {$
starts 1 2012/04/02 09:54:36;$
ends 1 2012/04/02 09:55:48;$
tstp 1 2012/04/02 09:55:48;$
cltt 1 2012/04/02 09:54:36;$
binding state free;$
hardware ethernet 33:14:22:c3:38:53;$
uid "\001\000\024\"\3038S";$
}$
$
il affiche rien:
root@BABALLE-01:~# sed -n '/^binding state free/,/^hardware/{/binding state free/b;/hardware/p}' h
root@BABALLE-01:~#
merci d'avance.
root@BABALLE-01:~# cat -A h
lease 192.168.100.10 {$
starts 3 2012/03/28 08:01:45;$
ends 3 2012/03/28 08:11:45;$
tstp 3 2012/03/28 08:11:45;$
cltt 3 2012/03/28 08:01:45;$
binding state free;$
hardware ethernet 22:20:d2:25:54:23;$
}$
lease 192.168.100.2 {$
starts 1 2012/04/02 09:54:36;$
ends 1 2012/04/02 09:55:48;$
tstp 1 2012/04/02 09:55:48;$
cltt 1 2012/04/02 09:54:36;$
binding state free;$
hardware ethernet 33:14:22:c3:38:53;$
uid "\001\000\024\"\3038S";$
}$
$
il affiche rien:
root@BABALLE-01:~# sed -n '/^binding state free/,/^hardware/{/binding state free/b;/hardware/p}' h
root@BABALLE-01:~#
merci d'avance.
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 12:16
11 avril 2012 à 12:16
Peux-tu mettre ton fichier sur Cjoint s'il te plaît, merci ?
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 12:22
11 avril 2012 à 12:22
voila un exemple
https://www.cjoint.com/?BDlmtdLPea2
c'est le fichier h avec qui j'ai essayé
merci d'avance
https://www.cjoint.com/?BDlmtdLPea2
c'est le fichier h avec qui j'ai essayé
merci d'avance
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 12:27
11 avril 2012 à 12:27
Voilà le problème, les fins de lignes à la sauce Micro$oft ;-((
D'une part, et d'autre part, c'est les espaces devant les lignes ;-((
Donc après avoir converti ton fichier au format Unix (dos2unix h.txt), essayer cette syntaxe :
Attention, il y a 2 espaces avant l'astérisque.
cat -A h.txt
lease 192.168.100.10 {^M$
starts 3 2012/03/28 08:01:45;^M$
ends 3 2012/03/28 08:11:45;^M$
tstp 3 2012/03/28 08:11:45;^M$
cltt 3 2012/03/28 08:01:45;^M$
binding state free;^M$
hardware ethernet 22:20:d2:25:54:23;^M$
}^M$
lease 192.168.100.2 {^M$
starts 1 2012/04/02 09:54:36;^M$
ends 1 2012/04/02 09:55:48;^M$
tstp 1 2012/04/02 09:55:48;^M$
cltt 1 2012/04/02 09:54:36;^M$
binding state free;^M$
hardware ethernet 33:14:22:c3:38:53;^M$
uid "\001\000\024\"\3038S";^M$
}^M$
^M$
D'une part, et d'autre part, c'est les espaces devant les lignes ;-((
Donc après avoir converti ton fichier au format Unix (dos2unix h.txt), essayer cette syntaxe :
sed -n '/^ *binding state free/,/^hardware/{/binding state free/b;/hardware/p}' h.txt
Attention, il y a 2 espaces avant l'astérisque.
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 12:41
11 avril 2012 à 12:41
super la ca marche pour l'instant
pourrai je avoir quelque explications de la commande sed parce que j'avoue que sed c'est pas du tt mon truc que t'avais utilisé
merci d'avance
pourrai je avoir quelque explications de la commande sed parce que j'avoue que sed c'est pas du tt mon truc que t'avais utilisé
merci d'avance
zipe31
Messages postés
36316
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 542
11 avril 2012 à 13:10
11 avril 2012 à 13:10
-n
Seule les informations qui nous intéressent seront affichées. Cette option marche avec le flag "p" que nous trouverons plus loin
/^ *binding state free/,/^hardware/
On sélectionne les lignes comprises dans l'intervalle correspondant aux deux motifs, chaque motif étant encadré par des slashs (/) et séparé par une virgule).
Le 1er doit commencer (^) par 2 espaces ou plus ( *) puis la chaîne de caractères "binding state free", et le 2nd doit commencer (^) par la chaîne de caractères "hardware"
{
Début du regroupement de commandes. Toutes les instructions qui se trouvent entre les 2 accolades s'appliqueront à l'intervalle visé.
/binding state free/b
Si la ligne contient le motif, ne rien faire et se brancher (commande "b") à la fin du script
/hardware/p
Si la ligne contient le motif, alors l'imprimer (commande "p")
}
Fin du regroupement de commandes
Seule les informations qui nous intéressent seront affichées. Cette option marche avec le flag "p" que nous trouverons plus loin
/^ *binding state free/,/^hardware/
On sélectionne les lignes comprises dans l'intervalle correspondant aux deux motifs, chaque motif étant encadré par des slashs (/) et séparé par une virgule).
Le 1er doit commencer (^) par 2 espaces ou plus ( *) puis la chaîne de caractères "binding state free", et le 2nd doit commencer (^) par la chaîne de caractères "hardware"
{
Début du regroupement de commandes. Toutes les instructions qui se trouvent entre les 2 accolades s'appliqueront à l'intervalle visé.
/binding state free/b
Si la ligne contient le motif, ne rien faire et se brancher (commande "b") à la fin du script
/hardware/p
Si la ligne contient le motif, alors l'imprimer (commande "p")
}
Fin du regroupement de commandes
othmane19
Messages postés
96
Date d'inscription
jeudi 16 avril 2009
Statut
Membre
Dernière intervention
27 avril 2013
11 avril 2012 à 18:15
11 avril 2012 à 18:15
un grand merci