back       next

comparing files line by line

Here's a way to compare two files that have common lines in both files:

sort file1.txt > file1_sorted.txt
sort file2.txt > file2_sorted.txt
comm -12 file1_sorted.txt file2_sorted.txt

Note: files need to be sorted first prior to comparing.

Post new comment

  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.