Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unterminated address regex while using sed

Tags:

linux

unix

sed

I am using the below command but while running the command in linux, getting the below error.

sed -n '/^[2015/01/01 03:46/,/^[2015/01/01 03:47/p' < Input.txt
sed: -e expression #1, char 42: unterminated address regex

KIndly help me on this.

like image 989
Dheeban Chakkaravarthy Avatar asked Jan 01 '15 09:01

Dheeban Chakkaravarthy


1 Answers

You need to escape the [, or else it thinks its start of a group, and escape to / in your data.

sed -n '/^\[2015\/01\/01 03:46/,/^\[2015\/01\/01 03:47/p' Input.txt

or (thanks to nu11p01n73R)

sed -n '\|^\[2015/01/01 03:46|,\|^\[2015/01/01 03:47|p' Input.txt
like image 73
Jotne Avatar answered Sep 19 '22 11:09

Jotne