Latest web development tutorials

Linux diffstat command

Linux command Daquan Linux command Daquan

Linux diffstat diff command based on the comparison, the statistics show.

diffstat read diff output, and statistics into each file, delete, modify the difference measurement.

grammar

diff [-wV][-n <文件名长度>][-p <文件名长度>]

Parameters:

  • -n <file name length> Specify the file name length, the length specified must be greater than or equal to the longest of all the files in the file name.
  • -p <file name length> and -n parameters the same, but where <filename length> including the path to the file.
  • -w Specifies the width of the output field.
  • -V Display version information.

Examples

Users also can use the "|" The results are diff command output directly to diffstat instruction statistical results show.

When you use this command, the next if the compared files or subdirectories not in the current directory, you should use its full path.

The file directory of the same name "test1" and "test2" under "testf.txt" using the diff command to compare. Then use the instructions diffstat results statistics, enter the following command:

$ diff test1 test2 | diffstat   #进行比较结果的统计显示

Note: Use this command can easily realize the function of statistics.

For viewing the contents of the file, the user can command "cat" to view, as follows:

$ cat test1/testf.txt           #查看test1/testf的内容  
abc  
def  
ghi  
jkl  
mno  
pqr  
stu  
vws  
$ cat test2/testf.txt           #查看test2/testf的内容  
abc  
def  
ghi  
jkl  
mno

From the contents of the file above shows, you can see the difference between the two file content. Now just run the command, and the results that compare statistics show the following results:

testfile | 2 +-             #统计信息输出显示  
1 file changed, 1 insertion(+), 1 deletion(-)

Linux command Daquan Linux command Daquan