Skip to main content
2 of 4
Added 'edit' in main post.
telometto
  • 2.2k
  • 4
  • 15
  • 39

Using sed to substitute text and add text after certain pattern

I'm looking to substitute text inside a file after a certain pattern.

For example:

The content of example.txt is

Something==x.y.z

I'd like to change it to

Something>=x.y.z,<x.y.z+1.0

I know I can use sed -i 's/==/>=/g' example.txt to change the == but I do not know add <x.y.z+1.0 after a certain pattern.

(Please note that x.y.z is a random number)

EDIT: it is for a Python package. I.e. argcomplete==1.12.3, youtube-dl==2021.6.6, systemd-python==234.

telometto
  • 2.2k
  • 4
  • 15
  • 39