Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

get rid of line that is not starting with specific word

I want to get rid of a line from a python file which is not starting with def.

thefile.py has

def showBuilder():
   """ Do something
       And build show
   """

showBuilder()

Now I want to leave the line def showBuilder as is but want to get rid of the line showbuilder() at the bottom

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried

sed '/^def / s/showBuilder()//' thefile.py

but this is returning

def :
   """ Do something
       And build show
   """

showBuilder()

would love to use anything that works, sed is just my try.

>Solution :

So match the line and the delete it.

sed '/^showBuilder()$/d'

You might find simpler to just:

grep -vxF 'showBuilder()'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading