Search code examples
sedgreptext-processing

Remove block of text stored in one file from another file


I have few tens of GB file. It contains repeating block of code I want to remove. I will copy this block of code into file named toBeRemoved and I'd like to run some command, without knowing internal structure of either file and remove all lines to be removed from huge file. The main requirement is not having to analyze block of text to be removed, so that you have just do

someCommand {anyNumberOfParameters} {fileWithBlockOfTextToBeRemoved} {fileToRemoveFrom}

do we have such someCommand?


Solution

  • Finally found the answer:

    pcregrep -v -F -f <(seq 2 4) <(for J in {1..5};do seq 5;done)
    

    for the large files you need to raise buffer.