Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to compare two files with diff to see what the differences are between those two files. The problem I have with it is that the diff output shows both files instead off showing me the differences only. There are lines in the two files that are exactly the same but are shown in the output anyhow instead of leaving them away.
The way I use diff is:
Code:
diff filename filename
So does anyone know what command I should use to only show the differences between files?
It could be that there's an extra bit of whitespace (spaces) at the end of the line, et cetera. Playing with the options may be of help -- the following are from the man page:
-b Ignore changes in amount of white space.
-B Ignore changes that just insert or delete blank lines.
-i Ignore changes in case; consider upper- and lower-case letters equivalent.
-I regexp Ignore changes that just insert or delete lines that match regexp.
--ignore-all-space Ignore white space when comparing lines.
I have tried the different options (I have also combind them) you mention, except "-I", but they do not work. I have also checked the lines that correspond to each other, but there's no extra whitespace. They are exactly the same.
If I put the corresponding lines from the two files into two new files, diff does not show differences though.
I do not understand what the "-I" option does. Can you explain to me how I can apply this, and do your have other suggestions pherhaps?
The lines diff are showing you are for context. The default is three lines before and after. If you use:
Code:
# diff -C0 file1 file2
then you will only see the different lines. "-U0" will also work if you prefer unified diff view. If you can't stand to see even diff's control lines then try:
Code:
# diff -C0 file1 file2 | grep -e "^\!"
Many output options are available if you look at "diff --help" or the man page.
I know now that the reason diff says the files differ is because the lines in the files are in a different order.
Besides the order everything is equal.
Does someone know with what command I can make the order of the lines equal?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.