Skip to main content
3 of 3
edited tags
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118

Replacing strings with regex in sed

I'm trying to use sed to replace the output of a command with regexp but can't figure it out the problem.

I tested the regex in regex101.com and it seems fine grouping the things that I want. But I cant understand how sed work with regexp groups patterns.

Here is the command output:

appstream CentOS Linux 8 - AppStream baseos CentOS Linux 8 - BaseOS epel Extra Packages for Enterprise Linux 8 - x86_64 epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64 extras CentOS Linux 8 - Extras 

And here is what I want to parse:

CentOS Linux 8 - AppStream CentOS Linux 8 - BaseOS Extra Packages for Enterprise Linux 8 - x86_64 Extra Packages for Enterprise Linux Modular 8 - x86_64 CentOS Linux 8 - Extras 

The sed regexp that I came up to is this:

sed -E 's/"(^.*?\s)([A-Z|a-x].*)"/\2/g' 

Can someone help me find the issue please?

Thanks!

kegham
  • 3
  • 1
  • 2