Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

howto delete completly a line in file 1

Status
Not open for further replies.

Bur

Technical User
Apr 16, 2002
12
FR
I would like to delete a line in a file matching a word i used s/^myword$//g.

exemple of file before
myword
otherword
otherword

exemple of file after

(blank line)
otherword
otherword

But the file appears with blank line.

how can remove completly the blank line ?
Thanks a lot for your help.
Bur.
 
change

s/^myword$//g

to

s/^myword\n$//

Just strip off the newline that is the cause of the blank line. For the particular match that you are using the 'g' modifier is unnecessary.

jaa
 
Thanks a lot justice41
I didn't know that \n could be replaca like that.
Many thanks
Bur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top