MLUG: Re: [MLUG] egep regexp in different unix OSes
Re: [MLUG] egep regexp in different unix OSes
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On Wed, Jul 09, 2003 at 01:13:37AM -0500, Mike Miller wrote:
> I wrote a tcsh script that had a line that looked like this:
> 
> egrep "^[ ]*${famID}[ ]+[#-~]+[ ]+[#-~]+[ ]+${momID}[ ]" $pedfile
> 
> In the line I really used, the "[ ]" was a [<space><tab>]' to represent
> white space.  That worked great on Solaris, but then I sent it to a friend
> of mine and it failed for him in Linux.  To make it work, he changed the
> regexp to the following:
> 
> "^\[\ \]\*${famID}\[\ \]+\[\!-z~\]+\[\ \]+\[\!-z~\]+\[\ \]+${momID}\[\ \]"
> 
> He took out the tab characters, so he could have done this instead:
> 
> "^ *${famID} +\[\!-z~\]+ +\[\!-z~\]+ +${momID} "
> 
> Does anyone know why the regexp I had written, and which worked under
> Solaris, failed under GNU/Linux?  I was a little surprised.  I don't
> unerstand why my friend had to escape the square brackets.  That would
> seem to imply that they should be interpretted literally.
> 
> All tips greatly appreciated!
> 
> Best,
> 
> Mike

Was your friend using the same shell as you?  Solaris seems to use tcsh 
and Linux seems to use bash.  Maybe they consider different things to be 
special characters.

Regards,
Mark (reading regexps makes my head hurt)
EMAIL:PROTECTED
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members