Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grep -v -x -F -f file2.txt file1.txt >file3.txt
- findstr /x /v /i /l /g:file2.txt file1.txt >file3.txt
- @echo off
- setlocal disableDelayedExpansion
- ::Define the files
- set "file1=test1.txt"
- set "file2=test2.txt"
- set "file3=test3.txt"
- ::Create an LF variable containing a line feed character
- set LF=^
- ::The above 2 blank lines are critical - do not remove
- ::Create a modified version of file2 that escapes any backslash
- ::EOL is set to a linefeed so that all non blank lines are preserved
- ::Delayed expansion is toggled on and off to protect ! characters
- >"%file2%.mod" (
- for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("%file2%") do (
- set "ln=%%A"
- setlocal enableDelayedExpansion
- echo(!ln:=\!
- endlocal
- )
- )
- ::Find lines in file1 that are missing from file2.mod
- findstr /vixlg:"%file2%.mod" "%file1%" >"%file3%"
- ::Delete the temporary file2.mod
- del "%file2%.mod"
- @echo off
- setlocal disableDelayedExpansion
- ::Define the files
- set "file1=test2.txt"
- set "file2=test.txt"
- set "file3=test3.txt"
- ::Create an LF variable containing a line feed character
- set LF=^
- ::The above 2 blank lines are critical - do not remove
- ::Find lines in file1 that are missing from file2.mod
- ::EOL is set to a linefeed character so that all non blank lines are preserved
- >"%file3%" (
- for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("%file1%") do (
- set "found="
- for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%B in ("%file2%") do (
- if %%A==%%B set found=1
- )
- if not defined found echo %%A
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement