简体   繁体   中英

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.

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. In case you want to save output into Input_file itself use sed -i in code too.

sed 's#\[.*\]##g'  Input_file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM