Hi,

> On Aug 22, 2020, at 10:13 PM, Budi <budikus...@gmail.com> wrote:
> 
> How anchor to line end in bash regex [[ ]]
> h=hi
> [[ $h =~ ^hi\$ ]] && echo Yes
> 
> cannot work, or is it bug yet

Special characters are matched literally if they are quoted, so you
just have to make sure the $ is not quoted.

        $ h=hi
        $ [[ $h =~ ^hi\$ ]] && echo Yes
        $ [[ $h =~ ^hi$ ]] && echo Yes
        Yes

vq

Reply via email to