You can use diff
in linux
diff file1.txt file2.txt
3a4
> 4444
Using grep
grep -vf file1.txt file2.txt
4444
Using awk
awk 'NR==FNR {a[$0]=1;next} !a[$0]' file1.txt file2.txt
4444
Вопрос
I've searched for solution but I still have problems with it. I have two files:
File1.txt
1111
2222
3333
File2.txt
1111
2222
3333
4444
and I want an output file with only differences:
File3.txt
4444
I've tried using Findstr but it doesn't work due to too large strings. I've also tried with gerp but I can;t make it to work.
Here's my batch code (it doesn't work because of too long strings):
findstr /vxg:vanilla_localisation.tsv mod_localisation.tsv > raf_changes.tsv
for /f %%a in ('^<raf_changes.tsv find /v /c ""') do echo %%a differences found
I've tried also with this code:
grep -f vanilla_localisation.tsv mod_localisation.tsv > raf_changes.tsv
but it creates only empty file. I'm windows user. Hope you will help me find solution.
Cheers
Решение 3
You can use diff
in linux
diff file1.txt file2.txt
3a4
> 4444
Using grep
grep -vf file1.txt file2.txt
4444
Using awk
awk 'NR==FNR {a[$0]=1;next} !a[$0]' file1.txt file2.txt
4444
Другие советы
This should work:
findstr /v /g:file1.txt file2.txt >result.txt
This works for 800 char I think - it won't be quick for 20000 lines.
@echo off
for /f "delims=" %%a in (file2.txt) do (
find "%%a" <"file1.txt" || >>result.txt echo %%a
)
PowerShell has a diff utility if that's an option;
@echo off
powershell "diff (Get-Content File1.txt) (Get-Content File2.txt) | foreach {$_.InputObject}" >result.txt
Use the comm utility (http://linux.101hacks.com/unix/comm-command-examples/):
comm -3 file1.txt file2.txt > file3.txt