Old.txt
contains
apple
orange
banana
And New.txt
contains
apple
orange
banana
grape
lemon
I can access new contents which are added to New.txt
using grep
command.
grep -Fxvf Old.txt New.txt > difference.txt
Now, difference.txt
contains
grape
lemon
In Windows, I have tried
findstr /rvc:Old.txt New.txt > difference.txt
to find the difference but it append contents of Old.txt
too. How can I write equivalent command in Windows?
You can use DOS
findstr
with the following flags:-
/v : Prints only lines that do not contain a match.
/g: file : Gets search strings from the specified file.
The command would be something like:-
C:\Users\dude\Desktop>findstr /v /g:Old.txt New.txt >difference.txt
Now checking the file output using the type
command; equivalent to cat
in Linux
, we see :-
C:\Users\dude\Desktop>type difference.txt
grape
lemon
Unless you are restricted from installing anything on your PC, considering installing ports of *nix-like tools such as GnuWin32 and continue to use grep.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With