Delete lines that are present in another file?

Delete lines that are present in another file?

16
Basic UserBasic User
16

    May 13, 2005#1

    Hi

    I have this "need" where I have 10+ lines in text file A. Everytime I have a new text file B (can be pretty hugh but can be sorted easily if need to), I need to DELETE lines in file B which are in file A.

    Or logically speaking,

    Take line 1 in file A, if line 1 found in file B, delete line in file B, repeat find/delete line 1 in file B until eof. Repeat with line 2 from file A and line 3 and so on until eof in file A.

    Or in another way of speaking, I have 10+ individual search strings contained in file A as separate text lines which if found in file B, delete these lines in file B.

    Can UltraCompare do this easily? Or can I accomplish this with macros in UltraEdit?

    Any ideas would be appreciated.

    Thanks.

    6,684586
    Grand MasterGrand Master
    6,684586

      May 13, 2005#2

      Can be done with an UE macro. The red lines just make sure, that file A ends with a line break (to avoid endless loop) and does not contain empty lines (to avoid deleting all empty lines in file B). If your file A is clean, file A should not be modified by the macro. Load only file A and B and make sure, file A is the current one before starting the macro.

      The macro property Continue if a Find with Replace not found or Continue if search string not found must be checked for this macro.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      NextWindow
      Top
      PreviousWindow
      Bottom
      IfColNum 1
      Else
      "
      "
      EndIf
      Top
      Loop
      Find "^p^p"
      Replace All "^p"
      IfNotFound
      ExitLoop
      EndIf
      EndLoop

      Top
      Loop
      SelectLine
      Copy
      EndSelect
      Key HOME
      NextWindow
      Find RegExp "%^c"
      Replace All ""
      PreviousWindow
      IfEof
      ExitLoop
      EndIf
      EndLoop

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
      Best regards from an UC/UE/UES for Windows user from Austria