[SATLUG] character classes with *
meekprize at gmail.com
Wed Oct 1 15:51:57 CDT 2014
the contents of his file is "aaLLyLayLaaya*?"
On Wed, Oct 1, 2014 at 3:46 PM, Bruce Dubbs <bruce.dubbs at gmail.com> wrote:
> MaxPower wrote:
>> 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
> lap007:~/crap$ cat testaaLLyLayLaaya*
> So what is the content of the file(s) named 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$ grep [abcde]* test
> ## once again total file returned aaLLyLayLaaya*
> lap007:~/crap$ grep [abcdef]* test
> ##the addition of the letter f returns a null set? buh?
> 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.
> First of all, the shell may be interpreting characters like [, ], and *.
> Eliminate that by enclosing in single quotes:
> grep '[abcdez]*' test
> Secondly, the above is asking to match zero or more of the characters a,
> b, c, d, e, or z. That probably matches anything but I really don't know
> the contents of the file you are asking about.
> -- Bruce
> 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