• # comm est la commande qu'il te faut

    Posté par . En réponse au message différences entre 2 fichiers. Évalué à -1.


    COMM(1) NetBSD General Commands Manual COMM(1)

    NAME
    comm -- select or reject lines common to two files

    SYNOPSIS
    comm [-123f] file1 file2

    DESCRIPTION
    The comm utility reads file1 and file2, which should be sorted lexically,
    and produces three text columns as output: lines only in file1; lines
    only in file2; and lines in both files.

    The filename ``-'' means the standard input.

    The following options are available:

    -1 Suppress printing of column 1.

    -2 Suppress printing of column 2.

    -3 Suppress printing of column 3.



    Pour que ca marche, il faut que les fichiers soient triés.

    droopy# cat A
    1
    2
    4
    A
    S

    droopy# cat B
    4
    S
    X
    3
    2
    1droopy# sort A >A.sorted
    droopy# cat ./A.sorted
    1
    2
    4
    A
    S
    droopy# sort B >B.sorted
    droopy# cat ./B.sorted
    1
    2
    3
    4
    S
    X

    droopy# comm -13 ./A.sorted ./B.sorted
    3
    X

    droopy# comm -23 ./A.sorted ./B.sorted
    A