DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Delete All Text In File Until Particular String  (Read 6,351 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 563
Delete All Text In File Until Particular String
« on: February 13, 2019, 10:18 AM »
Wondering how one might delete all text up until finding a particular text string.

Suppose the text string is “WXYZ”.

And suppose there are around 100 lines above the “WXYZ” line.

Too, suppose we have 1000 files to do this to.

Any suggestions appreciated.

Nicholas Kormanik

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: Delete All Text In File Until Particular String
« Reply #1 on: February 13, 2019, 11:28 AM »
Use sed, the Stream EDitor, known from Linux, but also available for Windows. And here is a SO answer with details

The Windows download can be found here: http://gnuwin32.sourceforge.net/packages/sed.htm
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 563
Re: Delete All Text In File Until Particular String
« Reply #2 on: February 15, 2019, 12:48 AM »
Thanks Ath.  Sed it is, then.

Original address: https://www.donationcoder.com/forum/index.php?topic=47179.0