课程: Ubuntu Linux: Essential Commands

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Compare text files

Compare text files

- [Instructor] Sometimes, we may need to compare our source code, configurations, logs, or other text files to discover changes. For that, we can use a tool called Diff. Diff shows us the differences between two files. So let's create a text file with a few lines in it. I write vi text1.txt I'll press I to move into Insert Mode and I'll write I'll save and quit by pressing Escape :WQ and I'll make a copy of that file. CP text1.txt text2.txt then I'll open up text2.txt and make a few changes. I'll write vi text2.txt I'll change text1 to text2 and I'll change few to couple of. I'll change short to brief and write to read and I'll add another line. Again, I'll save this with Escape:WQ Now we can use the Diff command to see the differences between text1 and text2. Let's think about what Diff is going to do by envisioning the first file as being on our left and the second file as being on our right. Normally, Diff doesn't actually show this, but with the dash y option, it will, so let's…

内容