[SATLUG] character classes with *

MaxPower rudebags at hotmail.com
Wed Oct 1 15:27:48 CDT 2014


Victim of formatting...  Let's see if I fixed it.
I'm having a bit of a hard time wrapping my head around what is actually going on here.  I'm attempting to learn about regular expressions and this use of character classes with * has me befuddled.
lap007:~/crap$ cat test
aa
L
Ly
Lay
Laay
a*
lap007:~/crap$ grep [abcdez]* test   ##why does this command include everything in the file (even the upper case L)?
aa
L
Ly
Lay
Laay
a*
lap007:~/crap$ grep [a-z]* test  ##while this command excludes everything in the file?
lap007:~/crap$ 
lap007:~/crap$ grep [abcde]* test  ## once again total file returned
aa
L
Ly
Lay
Laay
a*
lap007:~/crap$ grep [abcdef]* test  ##the addition of the letter f returns a null set?  buh?
lap007:~/crap$ 

I understand that * isn't being used in its normal way and while I grasp the logic behind grep [a-z].* test, grep [a-z]\* test, and grep '[a-z]*' the above has me quite miffed.
Thank you in advance for any clearing of the mud!

> From: rudebags at hotmail.com
> To: satlug at satlug.org
> Date: Wed, 1 Oct 2014 15:21:50 -0500
> Subject: [SATLUG] character classes with *
> 
> I'm having a bit of a hard time wrapping my head around what is actually going on here.  I'm attempting to learn about regular expressions and this use of character classes with * has me befuddled.
> lap007:~/crap$ cat testaaLLyLayLaaya*
> lap007:~/crap$ grep [abcdez]* test   ##why does this command include everything in the file (even the upper case L)?aaLLyLayLaaya*
> lap007:~/crap$ grep [a-z]* test  ##while this command excludes everything in the file?lap007:~/crap$ 
> lap007:~/crap$ grep [abcde]* test  ## once again total file returnedaaLLyLayLaaya*
> lap007:~/crap$ grep [abcdef]* test  ##the addition of the letter f returns a null set?  buh?lap007:~/crap$ 
> 
> I understand that * isn't being used in its normal way and while I grasp the logic behindgrep [a-z].* test, grep [a-z]\* test, and grep '[a-z]*' the above has me quite miffed.
> Thank you in advance for any clearing of the mud!
>  		 	   		  -- 
> _______________________________________________
> SATLUG mailing list
> SATLUG at satlug.org
> http://alamo.satlug.org/mailman/listinfo/satlug to manage/unsubscribe
> Powered by Rackspace (www.rackspace.com)
 		 	   		  


More information about the SATLUG mailing list