Home > database >  How to replace matching string by its content in parentheses in shell
How to replace matching string by its content in parentheses in shell

Time:07-23

I'm trying to produce a shell script which is formatting commits in Shell. After making a git log, I use grep to delete useless lines and now I want to change this :

feat(my-feat): my commit

to this:

my-feat: my commit

I want to write directly in a file: git log ... | grep -v ... >> CHANGELOG.md

Do you please have an idea how to achieve this ?

Thank you.

CodePudding user response:

Using sed

$ sed 's/[^(]*(\([^)]*\))/\1/' input_file > new_file
$ cat new_file
my-feat: my commit
  • Related