Desagrupar saída do diff

0

Eu tenho dois arquivos e a saída de diff é assim:

33428,33429c33428,33429
< lucid-security|main|icedtea-6-jre-cacao|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|icedtea6-plugin|6b20-1.9.2-0ubuntu1~10.04.1
---
> lucid-security|main|icedtea-6-jre-cacao|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|icedtea6-plugin|6b20-1.9.4-0ubuntu1~10.04.1
33835,33842c33835,33842
< lucid-security|main|openjdk-6-dbg|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-demo|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-doc|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jdk|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jre|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jre-headless|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jre-lib|6b20-1.9.2-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-source|6b20-1.9.2-0ubuntu1~10.04.1
---
> lucid-security|main|openjdk-6-dbg|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-demo|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-doc|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jdk|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jre|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jre-headless|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jre-lib|6b20-1.9.4-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-source|6b20-1.9.4-0ubuntu1~10.04.1
34182c34182
< lucid-security|universe|openjdk-6-jre-zero|6b20-1.9.2-0ubuntu1~10.04.1
---
> lucid-security|universe|openjdk-6-jre-zero|6b20-1.9.4-0ubuntu1~10.04.1

Eu gostaria de "desagrupar" a saída, então a linha antiga é seguida pela nova linha. Poderia ser assim:

< lucid-security|main|icedtea-6-jre-cacao|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|icedtea-6-jre-cacao|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|icedtea6-plugin|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|icedtea6-plugin|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-dbg|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-dbg|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-demo|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-demo|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-doc|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-doc|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jdk|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jdk|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jre|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jre|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jre-headless|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jre-headless|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-jre-lib|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-jre-lib|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|main|openjdk-6-source|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|main|openjdk-6-source|6b20-1.9.4-0ubuntu1~10.04.1
< lucid-security|universe|openjdk-6-jre-zero|6b20-1.9.2-0ubuntu1~10.04.1
> lucid-security|universe|openjdk-6-jre-zero|6b20-1.9.4-0ubuntu1~10.04.1

Não preciso das informações sobre a posição das linhas alteradas e nem me importo com as linhas adicionadas ou excluídas no segundo arquivo. Apenas esta rápida comparação de mudanças.

    
por mkudlacek 27.01.2011 / 12:24

1 resposta

1

Um regex rápido pode ordenar quais linhas são prefixadas por um determinado caractere.

diff file1 file2 | egrep '^[<>]' > output.txt

Isso deve deixá-lo apenas com alterações positivas e negativas, sem números de linha, sem separadores.

    
por 27.01.2011 / 12:31

Tags