Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have file1 that contains lines exactly the same as file2 BUT file 2 has more lines. I need to extract these additional line ONLY. I tried diff command but the output really long and I need just the additional lines. Can anybody help ?

share|improve this question

migrated from Aug 21 '12 at 21:03

This question came from our site for professional and enthusiast programmers.

I believe different will do what you want but I don't know the exact options. They should be able to help over at superuser – John Watts Aug 20 '12 at 21:24
2 – Doug Ramsey Aug 20 '12 at 21:25
You can also use graphical tools like meld. – Mechanical snail Aug 21 '12 at 21:10
up vote 5 down vote accepted

Try diff -w it will ignore the all whitespaces. Further, you can pipe your output to more this way you'll be able to view all the differences:

 diff -w file1 file2 | more

If you want a nicer display you can use the switch -y which will display two pages side-by side, and -l will add pagination:

diff -wyl file1 file2
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.