Skip to main content

Print duplicate lines found in files using sort and uniq commands.

#!/usr/bin/env bash

##
# Print duplicate lines in files.
# 
# sort opts
# 	(-f) to ignore the case of a letter when ordering lines.
#
# uniq opts
# 	(-i) to ignore case differences.
# 	(-c) to count the number of occurrences.
# 	(-d) to only output lines that are repeated.
##

cat <file_1> <file_2> | sort -f | uniq -i -d