Merci mille fois cela me f�t fort utile.

Alors pour poursuivre encore plus en avant mon exploration de ce fichier
texte de 200MO, voici ce que je souhaiterais faire.

Mon fichier est extrait d'une bande EXABYTE, il est en ASCII aux normes
ISO2709 (pour info), donc il faut savoir que toutes les infos se retrouvent
sur la m�me ligne !!! et qu'� ma connaissance aucun caract�res ne permet de
d�limiter les enregistrements !!!!!

La commande grep m'a permis de faire des recherches sur des cha�nes de
caract�re unique et donc de v�rifier la pr�sence de certaines infos.

MAIS maintenant je voudrais pousser le vice en affichant les x caract�res
pr�sent AVANT et APRES ma cha�ne en question  :-).........puis-je encore
utiliser les scripts pour grep ou dois-je forc�ment tomber dans les premiers
pas en C ???????? gloups

-----Message d'origine-----
De : Francois BOTTIN [mailto:[EMAIL PROTECTED]
Envoy� : jeudi 6 d�cembre 2001 11:06
� : Nicolas SABOURET
Cc : [EMAIL PROTECTED]; French liste
Objet : Re: [Pour �tre pr�cis] Re: grep ou awk


 --- Nicolas SABOURET <[EMAIL PROTECTED]> wrote: > Nicolas
SABOURET wrote:
> >
> > if [ grep -c "cha�ne" -gt 0 ]; then ...
> >
>
> grep -c "chaine" nomfichier en fait, et entre ` (backquote) si c'est
> dans le "if".
>
> Pardon d'avoir �t� approximatif.
>

Je dirais m�me plus : �tant donn� que le fichier peut �tre tr�s gros,
il est s�rement plus indiqu� de sortir d�s qu'une occurence est
trouv�e, et non pas aller jusqu'� la fin pour compter toutes les
occurences (option -c).

Extrait du man de grep :
-q, --quiet, --silent
       Quiet;  suppress  normal output.  The scanning will
       stop on the first match.  Also see the -s or  --no-
       messages option below.
[...]
-s, --no-messages
       Suppress  error  messages  about   nonexistent   or
       unreadable  files.   Portability  note:  unlike GNU
       grep, traditional grep did not conform to  POSIX.2,
       because traditional grep lacked a -q option and its
       -s option behaved like GNU grep's -q option.  Shell
       scripts intended to be portable to traditional grep
       should avoid both -q and  -s  and  should  redirect
       output to /dev/null instead.

Donc un -q me semble plus appropri� dans le cas d'un grep conformant �
POSIX.2 (cas du grep GNU), ou -s pour un grep "traditionnel" ...

Le test se fait alors sur le code de sortie (stock� dans la variable
shell $?) :

Normally, exit status is 0 if matches were found, and 1 if
no  matches  were found.  (The -v option inverts the sense
of the exit status.)  Exit status is 2 if there were  syn-
tax  errors  in  the pattern, inaccessible input files, or
other system errors.

    Fran�ois.

=====
Francois BOTTIN
--
    "How kind," the PFY sighs. "But where will I go?"
    "Somewhere where they know nothing about computing...
where they wouldn't know a RAM chip from a potato chip!"
    "But I don't want to visit Microsoft!" he whines.
              The BOFH 1998 - Simon Travaglia (bofh.ntk.net)

________________________________________________________________
Nokia 5510 looks weird sounds great.
Go to http://uk.promotions.yahoo.com/nokia/ discover and win it!
The competition ends 16 th of December 2001.


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]

Répondre à