2016-11-22 2 views

Répondre

1

Vous pouvez utiliser la commande diff comme

diff -a --suppress-common-lines file2 file1 

(Ou) Utilisez grep comme

grep -Fxvf file1 file2 

Avec les drapeaux suivants,

-F, --fixed-strings 
       Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.  
-x, --line-regexp 
       Select only those matches that exactly match the whole line. 
-v, --invert-match 
       Invert the sense of matching, to select non-matching lines. 
-f FILE, --file=FILE 
       Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. 

Une autre façon en utilisant awk

awk 'NR == FNR {unique[$0]++; next} !($0 in unique)' file1 file2 
+0

'grep -Fxvf' regarder slike ce que je veux, mais quand Je cours, je n'ai pas de sortie. – cflinspach

+1

A bien fonctionné pour moi. La commande diff n'a pas fonctionné aussi? – Inian

+1

@red_eagle: essayez la solution dans awk dans la dernière mise à jour, qui devrait fonctionner pour vous. – Inian