I have a long list of something like:
AllowedUsers aaaa01@11.22.33.44 aaaa03@11.22.55.77 bbbb11@99.99.99.99 ccc00@11.0.0.11 .....
all in single line. Basically it's bunch of username@ip
I wanted to do a find and replace just by using its username (e.g. aaa) and replace it with nothing.
I tested my regex (RegExr) and it works as I expected. But when I try to do it on sed
, it didn't work.
$ sed 's/bbbb11.*?(?= )//' test
AllowedUsers aaaa01@11.22.33.44 aaaa03@11.22.55.77 bbbb11@99.99.99.99 ccc00@11.0.0.11 .....
I also tried using bbbb11.*?(?=[[:space:]])
, it didn't work either.
Did I miss something?
sed
utility expects a POSIX basic regular expression, or a POSIX extended regular expression if you use its non-standard-E
option. This question appears to be a duplicate of Why does my regular expression work in X but not in Y? – Kusalananda Feb 04 '20 at 06:07