Find out the different lines of two text files

Source: Internet
Author: User

using the shell to find out two different lines of text files The method of the experiment is as follows: The first type: The Comm command method is as follows: Comm-3file1 File2 One problem is that if two files are sorted differently, there will be problems. The second: the grep command command is as follows: grep-vWF file1 file2 statistics file1 not, file2 in some of the specific use of the environment to Supplement, today first recorded here. Reference Documentation:1, find the same and different contents of two files: http://blog.csdn.net/shuckstark/article/details/78721762, Comm command: http://michaels.blogbus.com/logs/44427299.html3, Linux grep usage: http://blog.csdn.net/greytree/article/details/4285324, linux grep command: TTP://www.cnblogs.com/end/archive/2012/02/21/2360965.html
find out two different data for a file #!/bin/sh function _diffab () {x=0 forIinch' Cat $1`; Do         forJinch' Cat $2`; Do                if[$i = =$j];then x=1                         Break; Fi Doneif[$x-ne1];then echo $i fi x=0Done }if[" $"==""] || [" $"==""];thenecho"Use like this : $ Filea Fileb"Else{_diffab $1$2_diffab $2$1}fi

$ comm--Helpusage:comm [OPTION] ... FILE1 file2compare sorted files FILE1 and FILE2 line by line. With no options, produce three-column output.  Column one containslines unique to FILE1, column of contains lines unique to File2,and column three contains lines common  to both files. -1Suppress column1(lines unique to FILE1)-2Suppress column2(lines unique to FILE2)-3Suppress column3(lines that appearinchboth files)--check-order Check that the input iscorrectly sorted, evenifAll input lines is pairable--nocheck-order DoNot check that the input iscorrectly sorted--output-delimiter=STR separate columns with str--help Display ThisHelp and exit--version output version information and exitnote, comparisons honor the rules specified by ' Lc_collate'.Examples:comm- Afile1 file2 Print only lines presentinchboth File1 and file2. Comm-3File1 file2 Print LinesinchFile1 notinchFile2, and vice versa. Report Comm Bugs to Bug-[Email Protected]gnu coreutils home page://www.gnu.org/software/coreutils/>General HelpusingGNU Software: //www.gnu.org/gethelp/>For complete documentation, Run:info coreutils'Comm Invocation'

Find out the different lines of two text files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.