Linux uses diff to compare the difference between two files

Function: Compare the differences between two files and display the information in different places.

Syntax: diff [options] FILES

The format of FILES:

  • FILE1 FILE2: The source is a file, and the target is also a file. These two files must be text files. Compare the similarities and differences of text files line by line. 
    eg diff 1.txt 2.txt
  • DIR1 DIR2: The source is a directory, and the target is a directory. The diff command compares text files with the same name in two directories, sorts them in alphabetical order, lists different binary files, lists public subdirectories, and lists files that only appear in one directory. 
    eg diff dir1 dir2
  • FILE DIR: The source is a file and the target is a directory. The diff command compares the source file with the file with the same name in the target directory. 
    eg diff 1.txt dir2
  • DIR FILE: The source is a directory, and the target is a file (not a directory). Among all the files in the source directory, the file with the same name as the target file will be used for comparison with the target file. 
    eg diff dir1 2.txt

Guess you like

Origin blog.csdn.net/hailangnet/article/details/79333110
Recommended