compara 2 matrizes eg. csv

0

Eu gostaria de saber se é possível comparar duas listas via shell. A configuração:

Lista " A " com cerca de 6000 entradas
Lista " B " com cerca de 300 entradas

É possível detectar quais são duplicados e que são únicos em " B "? Existe uma maneira de salvá-los em um arquivo extra?

Obrigado

    
por Curtis Timo Schmidt 28.07.2014 / 15:17

1 resposta

0

Se (como eu suponho) você quiser comparar dois arquivos ASCII / Text, você pode usar o FC:

FC.exe

Compare the contents of two files or sets of files. Display any lines which do NOT match.

Syntax
      FC /B pathname1 pathname2

      FC [options] pathname1 pathname2

Key
   /B  : Perform a binary comparison.

options
   /C  : Do a case insensitive string comparison

   /A  : Displays only first and last lines for each set of differences.

   /U  : Compare files as UNICODE text files.
   /L  : Compares files as ASCII text. (default)

   /N  : Display line numbers (ASCII only)

   /LBn: Limit the number of lines that will be read, "n" sets a maximum number
         of consecutive differing lines after which the File Comparison will abort (resync failed)
         When FC aborts then "n" number of mismatches will be shown.
         default=100 lines.

  /nnnn  : Specify a number of consecutive lines that must match after a mismatch.
           This can be used to prevent the display of the two files from getting 
           too out of sync

  /T     : Do not expand tabs to spaces.
  /W     : Compress white space (tabs and spaces) for comparison.

To compare sets of files, use wildcards in pathname1 and pathname2 parameters.

Powershell also has an Alias FC for the Format-Custom cmdlet, therefore to run the 'old' FC under powershell you need to explicitly run C:\windows\system32\fc.exe

To identify 2 identical files use this syntax:

   FC file1.txt file2.txt | FIND "FC: no dif" > nul 
   IF ERRORLEVEL 1 goto :s_files_are_different
    
por 28.07.2014 / 15:23

Tags