Linux cmp and diff commands|Linux commands for devops |difference between cmp and diff
CMP = command is used for comparing the byte by byte of text information of a file and outputs the first difference of the file. cat list1.txt green blue yellow white cat list2.txt green blue black white cmp list1.txt list2.txt output:- list1.txt list2.txt differ: byte 6, line 2 ------------------------------------------------------------------------------------------------------------------------------------- diff = it is used for comparting two text files and displays all the mis-matches in the files. In addition it displays special symbols helping us in understanding what we should do to make those two files identical. a = add c = change the text of the file d = delete line In addition to this it displays the mis-match lines with notation. = indicates the right side file = indicates suggestion should be applied to left side file 2,5c3 =in the left file from 2 - 5 lines should be replaced with 3 line of the right file contents. diff stations1.txt stations2.txt 2c2 ooty ------------------------------------------------------------------------------------------------------------------------- simla 2nd line of left file should be changed with 2nd line of the right side file. diff list1.txt list22.txt 0a1 king 0th line of left file should be added with 1st of right side file. 0th line leftside add what 1 st line of right side file
Comments
Post a Comment