Re: How to match regex in bash? (any character)

2011-11-17 Thread Linda Walsh
Chet Ramey wrote: On 9/27/11 6:41 PM, Roger wrote: Correct. After reading the entire Bash Manual page, I didn't see much mention of documentation resources (of ERE) besides maybe something about egrep from Bash's Manual Page or elsewhere on the web. After extensive research for

Re: How to match regex in bash? (any character)

2011-10-03 Thread Stephane CHAZELAS
2011-10-02, 21:51(-04), Chet Ramey: On 10/2/11 3:43 PM, Stephane CHAZELAS wrote: [*] actually, bash does some (undocumented) preprocessing on the regexps, so even the regex(3) reference is misleading here. Not really. The words are documented to undergo quote removal, so they undergo quote

Re: How to match regex in bash? (any character)

2011-10-03 Thread Andreas Schwab
Stephane CHAZELAS stephane_chaze...@yahoo.fr writes: The problem and confusion here comes from the fact that \ is overloaded and used by two different pieces of software (bash and the system regex). That's nothing new. The backslash is widely used as a quote character in several languages,

Re: How to match regex in bash? (any character)

2011-10-03 Thread Stephane CHAZELAS
2011-10-03, 13:48(+02), Andreas Schwab: Stephane CHAZELAS stephane_chaze...@yahoo.fr writes: The problem and confusion here comes from the fact that \ is overloaded and used by two different pieces of software (bash and the system regex). That's nothing new. The backslash is widely used as

Re: How to match regex in bash? (any character)

2011-10-02 Thread Chet Ramey
On 10/2/11 3:43 PM, Stephane CHAZELAS wrote: [*] actually, bash does some (undocumented) preprocessing on the regexps, so even the regex(3) reference is misleading here. Not really. The words are documented to undergo quote removal, so they undergo quote removal. That turns \1 into 1, for

Re: How to match regex in bash? (any character)

2011-10-01 Thread rogerx . oss
On Thu, Sep 29, 2011 at 11:53:20PM -0800, Roger wrote: On Fri, Sep 30, 2011 at 06:20:32AM +, Stephane CHAZELAS wrote: 2011-09-29, 13:52(-08), Roger: [...] Since you're saying the regex description is found within either regex(3) or regex(7), couldn't there be a brief note within the Bash

Re: How to match regex in bash? (any character)

2011-09-30 Thread Stephane CHAZELAS
2011-09-29, 13:52(-08), Roger: [...] Since you're saying the regex description is found within either regex(3) or regex(7), couldn't there be a brief note within the Bash Manual Page be something to the effect: [...] No, it's not. I suppose bash could say: See your system regex(3)

Re: How to match regex in bash? (any character)

2011-09-30 Thread Roger
On Fri, Sep 30, 2011 at 06:20:32AM +, Stephane CHAZELAS wrote: 2011-09-29, 13:52(-08), Roger: [...] Since you're saying the regex description is found within either regex(3) or regex(7), couldn't there be a brief note within the Bash Manual Page be something to the effect: [...] No,

Re: How to match regex in bash? (any character)

2011-09-29 Thread Chet Ramey
Seems I used 'man regex' as well here. AKA regex(3). But I did realize this a few weeks ago; the real regex description being 'man 7 regex'. The Bash Manual Page denotes only regex(3). Not all the world is Linux. The regex(3) reference is the only one that is consistent across different

Re: How to match regex in bash? (any character)

2011-09-29 Thread Greg Wooledge
On Wed, Sep 28, 2011 at 12:43:01PM -0800, Roger wrote: Seems I used 'man regex' as well here. AKA regex(3). But I did realize this a few weeks ago; the real regex description being 'man 7 regex'. The Bash Manual Page denotes only regex(3). You're relatively fortunate that it's *that* easy to

Re: How to match regex in bash? (any character)

2011-09-29 Thread Peng Yu
On Thu, Sep 29, 2011 at 7:22 AM, Greg Wooledge wool...@eeg.ccf.org wrote: On Wed, Sep 28, 2011 at 12:43:01PM -0800, Roger wrote: Seems I used 'man regex' as well here.  AKA regex(3).  But I did realize this a few weeks ago; the real regex description being 'man 7 regex'. The Bash Manual Page

Re: How to match regex in bash? (any character)

2011-09-29 Thread Chet Ramey
On 9/29/11 9:48 AM, Peng Yu wrote: Therefore, either bash manpage should specify clearly which regex manpage it should be in each system (which a bad choice, because there can be a large number of systems), or the bash manpage should omit all the non consistent reference and say something

Re: How to match regex in bash? (any character)

2011-09-29 Thread Peng Yu
On Thu, Sep 29, 2011 at 10:38 AM, Chet Ramey chet.ra...@case.edu wrote: On 9/29/11 9:48 AM, Peng Yu wrote: Therefore, either bash manpage should specify clearly which regex manpage it should be in each system (which a bad choice, because there can be a large number of systems), or the bash

Re: How to match regex in bash? (any character)

2011-09-29 Thread Chet Ramey
On 9/29/11 11:59 AM, Peng Yu wrote: On Thu, Sep 29, 2011 at 10:38 AM, Chet Ramey chet.ra...@case.edu wrote: On 9/29/11 9:48 AM, Peng Yu wrote: Therefore, either bash manpage should specify clearly which regex manpage it should be in each system (which a bad choice, because there can be a

Re: How to match regex in bash? (any character)

2011-09-29 Thread Greg Wooledge
On Thu, Sep 29, 2011 at 10:59:19AM -0500, Peng Yu wrote: We all have discovered that regex(3) is not consistent across all the platform. Why you say it is portable? The three systems I mentioned earlier today all have regex(3). Which system have you found, which doesn't have it? As I

Re: How to match regex in bash? (any character)

2011-09-29 Thread Peng Yu
On Thu, Sep 29, 2011 at 11:06 AM, Greg Wooledge wool...@eeg.ccf.org wrote: On Thu, Sep 29, 2011 at 10:59:19AM -0500, Peng Yu wrote: We all have discovered that regex(3) is not consistent across all the platform. Why you say it is portable? The three systems I mentioned earlier today all have

Re: How to match regex in bash? (any character)

2011-09-29 Thread Roman Rakus
On 09/29/2011 06:18 PM, Peng Yu wrote: Also, regex(3) does not mention the difference between $x =~ .txt and $x=~ .txt. I think that the difference should be addressed in man bash. It is in man bash. RR

Re: How to match regex in bash? (any character)

2011-09-29 Thread Greg Wooledge
On Thu, Sep 29, 2011 at 11:18:57AM -0500, Peng Yu wrote: Also, regex(3) does not mention the difference between $x =~ .txt and $x=~ .txt. I think that the difference should be addressed in man bash. It already is. An additional binary operator, =~, is available, with the

Re: How to match regex in bash? (any character)

2011-09-29 Thread Chet Ramey
On 9/29/11 12:06 PM, Greg Wooledge wrote: As I mentioned previously, the best is to add a few examples in man bash. I would not object to that, but I can't speak for Chet. As I said, I will add examples to the info manual and some more explanation to the man page. Regular expressions are

Re: How to match regex in bash? (any character)

2011-09-29 Thread Chet Ramey
On 9/29/11 1:46 PM, Greg Wooledge wrote: An additional binary operator, =~, is available, with the same precedence as == and !=. When it is used, the string to the right of the operator is considered an extended regular expression and matched

Re: How to match regex in bash? (any character)

2011-09-29 Thread Roger
On Thu, Sep 29, 2011 at 12:06:08PM -0400, Chet Ramey wrote: On 9/29/11 11:59 AM, Peng Yu wrote: On Thu, Sep 29, 2011 at 10:38 AM, Chet Ramey chet.ra...@case.edu wrote: On 9/29/11 9:48 AM, Peng Yu wrote: Therefore, either bash manpage should specify clearly which regex manpage it should be in

Re: How to match regex in bash? (any character)

2011-09-27 Thread Greg Wooledge
On Mon, Sep 26, 2011 at 07:06:30PM -0800, Roger wrote: Some good reading I found is under the Bash Manual Page section Parameter Expansion. From here, to learn more about regex/regexpr as the Bash Manual is quite brief on regex, use the following manual pages: perlretut - Gives a good

Re: How to match regex in bash? (any character)

2011-09-27 Thread Roger
On Tue, Sep 27, 2011 at 08:15:09AM -0400, Greg Wooledge wrote: On Mon, Sep 26, 2011 at 07:06:30PM -0800, Roger wrote: Some good reading I found is under the Bash Manual Page section Parameter Expansion. From here, to learn more about regex/regexpr as the Bash Manual is quite brief on

Re: How to match regex in bash? (any character)

2011-09-27 Thread Chet Ramey
On 9/27/11 6:41 PM, Roger wrote: Correct. After reading the entire Bash Manual page, I didn't see much mention of documentation resources (of ERE) besides maybe something about egrep from Bash's Manual Page or elsewhere on the web. After extensive research for regex/regexpr, only found Perl

How to match regex in bash? (any character)

2011-09-26 Thread Peng Yu
Hi, I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't match txt. Does anybody know how to match any character (should be '.' in perl) in

Re: How to match regex in bash? (any character)

2011-09-26 Thread Steven W. Orr
On 9/26/2011 9:19 PM, Peng Yu wrote: Hi, I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't match txt. Does anybody know how to match any

Re: How to match regex in bash? (any character)

2011-09-26 Thread Dennis Williamson
On Mon, Sep 26, 2011 at 8:19 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't match txt.

Re: How to match regex in bash? (any character)

2011-09-26 Thread John Reiser
Peng Yu wrote: I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't match txt. Does anybody know how to match any character (should be '.'

Re: How to match regex in bash? (any character)

2011-09-26 Thread Peng Yu
On Mon, Sep 26, 2011 at 9:49 PM, John Reiser jrei...@bitwagon.com wrote: Peng Yu wrote: I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't

Re: How to match regex in bash? (any character)

2011-09-26 Thread Roger
On Mon, Sep 26, 2011 at 08:19:27PM -0500, Peng Yu wrote: Hi, I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't match txt. Does anybody know

Re: How to match regex in bash? (any character)

2011-09-26 Thread Roger
On Mon, Sep 26, 2011 at 09:37:07PM -0500, Dennis Williamson wrote: On Mon, Sep 26, 2011 at 8:19 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single