[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Steven W. Orr
Subject: Re: How to match regex in bash? (any character)
Date: Mon, 26 Sep 2011 21:56:31 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20110902 Thunderbird/3.1.14

On 9/26/2011 9:19 PM, 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 xxxxtxt. Does anybody know how to match any character
(should be '.' in perl) in bash.

[[ "$1" =~ "xxx.txt" ]]

Looks good to me.

513 > regex='xxx.txt'
514 > [[ xxxxtxt =~ $regex ]]
515 > echo $?
516 >

Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]