[英]Sed replace between and including 2 patterns
Hi guys I am doing the following 大家好,我正在做以下
sed -i -e 's/[.*]//g'
I am trying to remove 2 known patterns and everything inbetween for each line. 我正在尝试删除2条已知模式以及每行之间的所有内容。
From 从
[01]Hello
I am[abc]
[123abc]Chris
To 至
Hello
I am
Chris
Can anyone spot where I am going wrong? 谁能发现我要去哪里错了?
Could you please try following here, making #
as sed
separator for more clarity. 您是否可以尝试在此处执行以下操作,将
#
用作sed
分隔符,以更清晰。 In case you want to save output into Input_file itself use sed -i
in code too. 如果您想将输出保存到Input_file本身,请在代码中也使用
sed -i
。
sed 's#\[.*\]##g' Input_file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.