Linux 比较两个文件并输出差异内容

Kevin 教程 1,887 次浏览 66条评论

问题描述:在 Linux 命令终端下对比 2 个文件内容,并分别显示它们之间的差异。

文件例子:

cat file1.txt
1
2
3
4
5
7

cat file2.txt
1
2
6
3
4
5
9
8

先直观查看下两个文件之间的差异对比。

diff -y file1.txt file2.txt
1                                                               1
2                                                               2
                                                              > 6
3                                                               3
4                                                               4
5                                                               5
7                                                             | 9
                                                              > 8

再用下面命令输出对比结果。

显示file1.txt文件里没有的内容。

grep -Fxvf file1.txt file2.txt
6
9
8

显示file2.txt文件里没有的内容。

grep -Fxvf file2.txt file1.txt
7

显示两个文件都有的相同内容。

grep -Fxf file1.txt file2.txt
1
2
3
4
5

评论列表

  1. #1

    Hi, very nice website, cheers!
    ——————————————————
    Need cheap and reliable hosting? Our shared plans start at $10 for an year and VPS plans for $6/Mo.
    ——————————————————
    Check here: https://www.reliable-webhosting.com/

  2. #2

    acyclovir suppressive therapy for herpes https://www.herpessymptomsinmen.org/productacyclovir/

  3. #3

    when will lumigan become generic https://carepro1st.com/

  4. #4

    viagra pills viagra without doctor https://buszcentrum.com/

  5. #5

    amoxicillin sample request form https://amoxycillin1st.com/

  6. #6

    ivermectin for head lice dose https://ivermectin.webbfenix.com/

  7. #7

    pregnancy with clomid 1st use https://salemeds24.wixsite.com/clomid

  8. #8

    mefloquine vs hydroxychloroquine https://hydroxychloroquine.webbfenix.com/

  9. #9

    vidalista over counter walmart https://vidalista.mlsmalta.com/

  10. #10

    hydroxychloroquine and cardiovascular risk https://hydroxychloroquine.mlsmalta.com/

  11. #11

    best price cialis 20mg http://www.lm360.us/

  12. #12

    mexican vidalista pills https://vidalista.buszcentrum.com/

  13. #13

    viagra generics price http://droga5.net/

  14. #14

    coupon for hydroxychloroquine https://hhydroxychloroquine.com/

  15. #15

    is a good thing.

    http://ozemigration.com/

  16. #16

    ivermectin for heartworm treatment https://ivermectin.mlsmalta.com/

  17. #17

    order generic vidalista https://vidalista40mg.mlsmalta.com/

  18. #18

    cialis daily side effects https://wisig.org/

  19. #19

    is dapoxetine from india safe https://ddapoxetine.com/

  20. #20

    albuterol sulfate generic name https://amstyles.com/

  21. #21

    what is the truth about hydroxychloroquine https://hydroxychloroquinee.com/

  22. #22

    erectile dementia
    best erectile dysfunction pills
    erectile problems and solutions

  23. #23

    Very interesting info !Perfect just what I was looking for!

    http://www.vreyrolinomit.com/

  24. #24

    erectile dysfunction remedies
    ed meds
    erectile injections
    ace inhibitors erectile dysfunction

  25. #25

    plaquenil side effects long term https://hydroxychloroquine.mymvrc.org/

  26. #26

    I am incessantly thought about this, thanks for posting. https://local-auto-locksmith.co.uk/

  27. #27

    Some really great info, Gladiola I detected this. I’m not spaming. I’m just saying your website is AWSOME! Thank you so much! Please vist also my website. https://local-auto-locksmith.co.uk/renault/

  28. #28

    I reckon something truly special in this website. https://chwilowki-pozyczka.pl/

  29. #29

    cefixime’s effect on women https://ceefexime.co/

  30. #30

    Some genuinely excellent content on this web site , thanks for contribution. Myriam Brian Durnan

  31. #31

    Paragraph writing is also a fun, if you be familiar with after that you can write otherwise it is complex to write. Tisha Lem Allx

  32. #32

    billing for plaquenil eye exam https://hydroxychloroquine4u.com/

  33. #33

    https://pussy888vip.com/
    I do the same thing I love

  34. #34

    Way cool! Some very valid points! I appreciate you penning this post and the rest of the site is also very good. Roxana Donn Yvonner

  35. #35

    I should really relisten to Daisy Jones and the Six. I loved that one and I can only imagine it being better the second time around. Tandy Zebulon Chiang

  36. #36

    Wonderful post! We are linking to this particularly great content on our site. Keep up the good writing. Marion Derron Maggi

  37. #37

    You need to be a part of a contest for one of the finest websites online. I most certainly will highly recommend this blog! Dorri Justino Odeen

  38. #38

    Every baker needs a signature snacking cake and Morning Glory Breakfast Cake is now mine. Made as directed with exception of subbing chopped pecans for the pepitas and it was perfect. Babbie Hill Karolyn

  39. #39

    What a fun choice! Pooh would have a lot to say about his adventures and it would be comical watching him eat his honey. Marcia Rafaello Katerine

  40. #40

    Thank for share this post
    วิธีดูราคาบอล

  41. #41

    Here are some of the websites we advise for our visitors Orelie Nichole Salazar

  42. #42

    I think the problem for me is the energistically benchmark focused growth strategies via superior supply chains. Compellingly reintermediate mission-critical potentialities whereas cross functional scenarios. Phosfluorescently re-engineer distributed processes without standardized supply chains. Quickly initiate efficient initiatives without wireless web services. Interactively underwhelm turnkey initiatives before high-payoff relationships. Nadiya Ronny Grimonia

  43. #43

    Hi there. I found your blog by means of Google at the same time as searching for a similar matter, your website got here up. It seems great. I have bookmarked it in my google bookmarks to visit then. Shaylynn Gaelan Israel

  44. #44

    liquid tadalafil peptides https://cialis.buszcentrum.com/

  45. #45

    liquid tadalafil peptides http://cialis.anafassia.com/

  46. #46

    hydroxychloroquine covid 19 http://hydroxychloroquined.online/

  47. #47

    interactions for cialis https://cialis.cleckleyfloors.com/

  48. #48

    interactions for cialis https://cialis.webbfenix.com/

  49. #49

    Si eu sunt focusata pe cadouri de craciun. As vrea sa rezolv totul din timp Nisse Falito Hennessey

  50. #50

    fantastic issues altogether, you just won a emblem new reader. What would you recommend about your publish that you made some days in the past? Any positive? Ann-Marie Bay Weinreb

  51. #51

    very good submit, i definitely love this website, carry on it Gerladina Halsy Mages

  52. #52

    Hi, Neat post. There is an issue along with your site in web explorer, might check this? IE nonetheless is the marketplace chief and a big portion of other people will leave out your fantastic writing because of this problem.| Christiane Yves Adim

  53. #53

    Shopping online is one of many things that makes the Internet so great. Though it is a simple thing to do, shopping online with success requires good information. Here are some tips that you can use to make sure your online shopping experience works. Marj Adolphus Leroy

  54. #54

    I’m gone to convey my little brother, that he should also visit this website on regular basis to get updated from most recent news update. http://antiibioticsland.com/Cipro.htm

  55. #55

    Cum zice si autorul articolui One pedal driving va fi norma. SI e normal sa fie asa. E mult mai sigur. Sa luam o persoana care are probleme cu reflexele. Va evita multe accidente grave pt ca ia piciorul de pe acceleratie si masina franeaza. Nu mai e nevoie sa ajunga cu piciorul pe frana ca sa inceapa procesul de franare. Corissa Doyle Delfine

  56. #56

    Hey are using WordPress for your site platform?

    I’m new to the blog world but I’m trying to get started and set
    up my own. Do you require any coding knowledge
    to make your own blog? Any help would be really appreciated! http://herreramedical.org/hydroxychloroquine

  57. #57

    I got what you mean ,saved to favorites, very nice web site.

    http://www.zortilonrel.com/

  58. #58

    Hello there, I found your blog via Google while looking for a comparable topic,
    your website came up, it seems great. I have bookmarked it in my google bookmarks.

    Hello there, just was alert to your weblog thru Google, and located that it’s truly informative.
    I’m gonna watch out for brussels. I will be grateful
    when you proceed this in future. Numerous folks will be benefited from your writing.

    Cheers! http://antiibioticsland.com/Tetracycline.htm

  59. #59

    buy hydroxychloroquine online https://hydroxychloroquinex.com/

  60. #60

    incrível este conteúdo. Gostei bastante. Aproveitem e vejam este conteúdo. informações, novidades e muito mais. Não deixem de acessar para descobrir mais. Obrigado a todos e até a próxima. 🙂

    https://corporality.global/

  61. #61

    Great post. I am facing a couple of these problems.

    http://www.easoar-soon.com

  62. #62

    Good day very cool site!! Man .. Beautiful .. Wonderful .. I will bookmark your blog and take the feeds additionally?KI am satisfied to find a lot of helpful information here in the put up, we’d like work out more techniques on this regard, thanks for sharing. . . . . .

    http://www.vreyrolinomit.com/

  63. #63

    Great article. https://cialis.confrancisyalgomas.com/tadalafil

  64. #64

    Good – I should certainly pronounce, impressed with your website. I had no trouble navigating through all tabs and related info ended up being truly simple to do to access. I recently found what I hoped for before you know it in the least. Quite unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your customer to communicate. Nice task.

    https://allcreditcarloans.co/buy-here-pay-here-lots/

  65. #65

    Wow! Thank you! I always wanted to write on my site something like that. Can I include a part of your post to my website?

    http://www.zortilonrel.com/

  66. #66

    Have you ever heard of second life (sl for short). It is essentially a game where you can do anything you want. SL is literally my second life (pun intended lol). If you want to see more you can see these second life articles and blogs

    ecampus.nmit.ac.nz/moodle/mod/forum/discuss.php?d=4797

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。