Menu

Delete text portion from a file between two search patterns

2015-06-08
2015-07-01
  • Gerhard Hofmann

    Gerhard Hofmann - 2015-06-08

    Hello,

    I have files to process that look like this:

    text before first pattern that should be kept
    text before first pattern that should be kept
    text before first pattern that should be kept
    PATTERN1
    text to be thrown away
    text to be thrown away
    PATTERN2
    text after second pattern that should be kept
    text after second pattern that should be kept
    text after second pattern that should be kept

    Desired result after processing:

    text before first pattern that should be kept
    text before first pattern that should be kept
    text before first pattern that should be kept
    text after second pattern that should be kept
    text after second pattern that should be kept
    text after second pattern that should be kept

    How could I do this with SFK XE?

    TIA
    Gerhard Hofmann

     
  • stahlworks

    stahlworks - 2015-06-08

    on a single file:

    sfk xreplace in.txt "/pattern1[bytes]pattern2[eol]//"
    

    on all .txt files of folder mydir:

    sfk xreplace -dir mydir -file .txt -pat "/pattern1[bytes]pattern2[eol]//"
    
     
  • Gerhard Hofmann

    Gerhard Hofmann - 2015-07-01

    Thanks for this helpful hint.

    Regards
    Gerhard Hofmann

     

Log in to post a comment.