Skip to content

Commit 0bacc3a

Browse files
committed
asdf
1 parent 9d95a78 commit 0bacc3a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

_notes/commandline-notes.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ Or the opposite, files without the phrase, using `-L` for filenames with no matc
106106

107107
`grep -L "string" * > list.txt`
108108

109+
## Compare two text files
110+
111+
To compare two text files you can use `diff` or `comm`.
112+
I often use this to find the difference between two folders or lists of files (`ls > filelist.txt`).
113+
114+
Diff will show a report something like a git diff:
115+
116+
`diff list1.txt list2.txt`
117+
118+
Comm will output a list comparing the lines in the two files, grouping them by lines only in file 1, only in file 2, and in both.
119+
Add the options `-1`, `-2`, or `-3` to not view one of those groupings.
120+
Generally, I just want the differences, so use `-3` to NOT see the lines that are the same in both.
121+
122+
`comm -3 list1.txt list2.txt > comparison.txt`
123+
109124
## Copy a list of files
110125

111126
I often have a folder of binary files, like images, where I need to sort out a small group to upload or move somewhere else.

0 commit comments

Comments
 (0)