Bash Print Lines Unique To One File

[Solved] Bash Print Lines Unique To One File | Perl - Code Explorer | yomemimo.com
Question : bash print lines unique to file

Answered by : charlesalexandre-roy

# Example usage 1:
awk 'NR==FNR { b[$0] = 1; next } !b[$0]' input_file_1 input_file_2
# Where:
#	- this returns all lines of input_file_2 that aren't found in input_file_1
# Note, remove the ! to return all lines in common between the files
# Example usage 2:
comm -23 input_file_1 input_file_2
# Where:
#	- this returns lines only found in input_file_1
comm -13 input_file_1 input_file_2
# Where:
#	- this returns lines only found in input_file_2
comm -12 input_file_1 input_file_2
# Where:
#	- this returns lines found in both input files

Source : https://unix.stackexchange.com/questions/392722/need-to-understand-below-awk-command-to-find-missing-lines-in-a-file/392725#392725 | Last Update : Thu, 08 Oct 20

Answers related to bash print lines unique to one file

Code Explorer Popular Question For Perl