使用sed时未终止的地址正则表达式 [英] unterminated address regex while using sed

查看:1065
本文介绍了使用sed时未终止的地址正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令,但是在linux中运行该命令时,出现以下错误.

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

请帮助我.

推荐答案

您需要转义[,否则它会认为它是一个组的开始,并转至数据中的/.

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

或(由于nu11p01n73R)

or (thanks to nu11p01n73R)

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

这篇关于使用sed时未终止的地址正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆