bug-bash
[Top][All Lists]
Advanced

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

Match newline character


From: pk
Subject: Match newline character
Date: Tue, 04 May 2010 15:48:51 -0000

Is the =~ operator supposed to recognize \n in patterns? Example:

$ a='abc
def'

$ if [[ $a =~ c\nd ]]; then echo ok; fi

The above produces no output (I've tried using \\n, \\\n too), while using a 
literal newline works:

$ if [[ $a =~ c$'\n'd ]]; then echo ok; fi
ok

Is that expected behavior or am I doing something wrong? I thought \n was 
pretty standard in regular expressions.

Thanks.


reply via email to

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