From bca6221ed3c0a67c0632f302978ec71cc1f9fa86 Mon Sep 17 00:00:00 2001 From: bonnie Date: Mon, 9 May 2022 00:01:41 +0800 Subject: [PATCH] edadd comm in "data wrangling" --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9492694..ec83d4b 100644 --- a/README.md +++ b/README.md @@ -2636,7 +2636,41 @@ sdiff fileA fileB ##### Compare two files, strip trailing carriage return/ nextline (e.g. fileA, fileB) ```bash - diff fileA fileB --strip-trailing-cr +diff fileA fileB --strip-trailing-cr +``` + +##### Find common/differing lines +```bash +# having two sorted and uniqed files (for example after running `$ sort -uo fileA fileA` and same for fileB): +# ------ +# fileA: +# ------ +# joey +# kitten +# piglet +# puppy +# ------ +# fileB: +# ------ +# calf +# chick +# joey +# puppy +# +# Find lines in both files +comm -12 fileA fileB +# joey +# puppy +# +# Find lines in fileB that are NOT in fileA +comm -13 fileA fileB +# calf +# chick +# +# Find lines in fileA that are NOT in fileB +comm -23 fileA fileB +# kitten +# piglet ``` ##### Number a file (e.g. fileA)