cmd - Compare TXT files and get missing words -


i have 2 txt files, first result of json file , second must contain content of json + content of other txt file.

database1.txt

word1 word2 word3 word8 

database2.txt (from json)

word1 word5 word7 word8 

database3.txt (database1+database2)

word1 word2 word3 word5 word7 word8 

here code:

@echo off setlocal enabledelayedexpansion if exist "%localappdata%\xxx\xxx\database.json". (  /f "delims=" %%a in ('type "%localappdata%\xxx\xxx\database.json"') %%b in (%%a) ( echo %%b >>json.tmp )  /f "tokens=* skip=1 delims= " %%a in (json.tmp) ( call :sub1 %%a  >> json_cl.txt echo.!s! )  set row= /f "delims=" %%j in (json_cl.txt) (   if  defined row echo.!row!>>password_jd.txt   set row=%%j )   findstr /v /g:"password_list.txt" "password_jd.txt">1.out         type password_list.txt 1.out>updated_pw.txt  del json_cl.txt del json.tmp del password_jd.txt del 1.out goto :eof  :sub1 set s=%* set s=!s:"=!  goto :eof ) 

the code works looks if findstr dosnt find missing word.

can me fix or can tell me better way compare ?

thank you

this script uses robust tool called uniq.bat aacini

@echo off copy database1.txt + database2.txt tmp.txt >nul type tmp.txt | sort |uniq >database3.txt del tmp.txt 

uniq.bat

@if (@codesection == @batch) @then  @cscript //nologo //e:jscript "%~f0" & goto :eof & rem aacini 2013  @end  var line, prevline = ""; while ( ! wscript.stdin.atendofstream ) {    line = wscript.stdin.readline();    if ( line != prevline ) {       wscript.stdout.writeline(line);       prevline = line;    } } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -