python - Delete contents of file before XXXXXX -


my question similar delete file contents after line == "xxxxxxx" instead of deleting part after term xxxxxx, want delete content before.

in spirit, let me put forward attempt :

i in python by:

f = open('paper.html') lines=f.readlines() in range(1,len(lines)):  if 'visible' in lines[it]:   counter=it   break  h = open('paper_sub.html','wa') in range(counter+1,len(lines)):  h.write(lines[it])  f.close() h.close() 

is there sed way of doing it?

sed -n '/.*visible.*/,$p' originalfile > newfile 

if don't want line visible

sed '1,/.*visible.*/d' originalfile > newfile 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -