Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. grep -v -x -F -f file2.txt file1.txt >file3.txt
  2.  
  3. findstr /x /v /i /l /g:file2.txt file1.txt >file3.txt
  4.  
  5. @echo off
  6. setlocal disableDelayedExpansion
  7.  
  8. ::Define the files
  9. set "file1=test1.txt"
  10. set "file2=test2.txt"
  11. set "file3=test3.txt"
  12.  
  13. ::Create an LF variable containing a line feed character
  14. set LF=^
  15.  
  16.  
  17. ::The above 2 blank lines are critical - do not remove
  18.  
  19. ::Create a modified version of file2 that escapes any backslash
  20. ::EOL is set to a linefeed so that all non blank lines are preserved
  21. ::Delayed expansion is toggled on and off to protect ! characters
  22. >"%file2%.mod" (
  23. for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("%file2%") do (
  24. set "ln=%%A"
  25. setlocal enableDelayedExpansion
  26. echo(!ln:=\!
  27. endlocal
  28. )
  29. )
  30.  
  31. ::Find lines in file1 that are missing from file2.mod
  32. findstr /vixlg:"%file2%.mod" "%file1%" >"%file3%"
  33.  
  34. ::Delete the temporary file2.mod
  35. del "%file2%.mod"
  36.  
  37. @echo off
  38. setlocal disableDelayedExpansion
  39.  
  40. ::Define the files
  41. set "file1=test2.txt"
  42. set "file2=test.txt"
  43. set "file3=test3.txt"
  44.  
  45. ::Create an LF variable containing a line feed character
  46. set LF=^
  47.  
  48.  
  49. ::The above 2 blank lines are critical - do not remove
  50.  
  51. ::Find lines in file1 that are missing from file2.mod
  52. ::EOL is set to a linefeed character so that all non blank lines are preserved
  53. >"%file3%" (
  54. for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("%file1%") do (
  55. set "found="
  56. for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%B in ("%file2%") do (
  57. if %%A==%%B set found=1
  58. )
  59. if not defined found echo %%A
  60. )
  61. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement