> 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 xxxxtxt. Does anybody know how to match any character >(should be '.' in perl) in bash. > >[[ "$1" =~ "xxx.txt" ]]
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 from the start explanation of regular expressions, including perl perlrequick - If you already know some perl, then just a quick start should do. There's a lot of Perl Manual Pages and 'man perltoc' will get you a full listing of manual pages including descriptions. (I'm currently reading the perlretut man page as I do not know much perl language at all!) Is it possible to get more documentation or examples into the Bash Manual concerning regex. Maybe some references to the above manual pages or are we talking severe conflict of interest? At the very least, one or two common Bash Parameter examples would be nice! -- Roger http://rogerx.freeshell.org/