PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > weird behavior of grep
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

weird behavior of grep

Réponse
 
LinkBack Outils de la discussion
Vieux 15/03/2008, 17h32   #1
dave_140390@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut weird behavior of grep

Hi,

I have a file that contains two lines of text:
small line
LARGE LINE

Let's call this file "test".

When I grep this file for "a", I get, as expected:
$ grep a test
small line

When I grep this file for "A", I get, as expected:
$ grep A test
LARGE LINE

Now, if I grep this file for [a-z], I get:
$ grep [a-z] test
small line
LARGE LINE

Now, _that_ is unexpected! Why on earth does grep return also the line
with only capital letters when the expression to search is "[a-z]"?!
Let me add that my environment variable GREP_OPTIONS is not set.

Any idea?

-- dave
  Réponse avec citation
Vieux 15/03/2008, 18h24   #2
pk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: weird behavior of grep

dave_140390@hotmail.com wrote:

> Now, if I grep this file for [a-z], I get:
> $ grep [a-z] test
> small line
> LARGE LINE


Try this:

$ grep '[[:lower:]]' test

and this:

$ LC_ALL=C grep '[a-z]' test

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
  Réponse avec citation
Vieux 16/03/2008, 00h47   #3
Maxwell Lol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: weird behavior of grep

dave_140390@hotmail.com writes:

> Now, if I grep this file for [a-z], I get:
> $ grep [a-z] test
> small line
> LARGE LINE
>
> Now, _that_ is unexpected!



try

echo grep [a-z] test

to see what grep REALLY gets as input.
(Remember, the shell parses meta-characters before grep seel them).


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h35.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10015 seconds with 11 queries