In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "the usage of the Linux basic command diffstat". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Diffstat
This program reads the output of diff and displays a histogram of inserts, deletions, and modifications of each file. Diffstat is a program for checking large and complex patch files. It reads from one or more input files that contain the diff output and generates a histogram of the total line changed for each file referenced. If the input file name ends with .bz 2, .gz, .lzma, .z, or .z, Diffstat will pipe the uncompressed data from the appropriate program. It can also infer the type of compression from standard input pipe files.
Diffstat recognizes the most popular type of output from diff:
Unified, the preferred patch.
Context, the best readable, but not very compact.
Default is not very good, but it is easy to produce.
Diffstat detects the lines output by diff to determine which files have been compared, and then counts the tags in the first column that represent the type of change (insert, delete, or modify). These are displayed as ","-"and"! "characters in the histogram. If no file name is specified on the command line, Diffstat reads the differences in standard input.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Diffstat [options] [file-specifications]
2. List of options
Option
Description
-b
Ignore lines in diff that match "binary files XXX and YYY are different"
-c
Add "#" to each line of output to make it a comment line for the shell script.
-D destination
Specify a directory that contains files that can be referenced as a result of applying differences. Diffstat calculates the number of lines in the corresponding file (after adjusting the name with the-p option) to get the total number of lines in each file.
-e file
Redirect standard error to a file
-f format
Specify the format of the histogram:
For brevity, it displays only the value and a histogram code insert (+), delete (-), or modify (!).
1, normal format.
2. Fill the histogram with points.
4, use the histogram to print each value.
Any non-zero value gives a histogram. Points and individual values can be combined, for example,-f6 gives both.
-h
Display help information and exit
-k
Prohibit merging file names in a report
-l
Only the file name is listed. No histogram is generated.
-m
Merge insert / delete counts from each "block" of the patch file to approach the count of modified lines
-n number
Specifies the minimum width used for the file name. If this is not specified, Diffstat uses the length of the longest file name after removing the common prefix.
-N number
Specifies the maximum width used for the file name. Names that exceed this limit are truncated on the left. If you do not specify this option, the-n option is checked below.
-o file
Redirect standard output to a file
-p number
Override the logic to delete the public pathname to simulate the patch "- p" option.
-Q
"0 File change" message suppressing null differences
-r code
Provides an optional rounding of the data shown in the histogram instead of truncating the data through error adjustment:
Is the default. No rounding operation is performed, but cumulative errors are added to the following.
1, round off the data.
2, round the data and adjust the histogram to ensure that something is displayed in the event of any differences, even if those differences are usually rounded to zero.
-S source
This is similar to the-D option, but specifies a location where the original file can be found (before the difference is applied).
-t
Rewrite the histogram to generate the output of comma-separated values.
-u
Forbids sorting of file names in the report.
-v
Displays progress, for example, if the output is redirected to a file, the progress message is written to standard error
-V
Display the version number and exit
-w number
Specifies the maximum width of the histogram. The histogram will never be smaller than 10 columns in case the file name is too large.
3. Environmental variables
Diffstat runs in a portable UNIX environment. You can override the compilation path of the program used to extract the input file by setting the environment variable corresponding to the name of the input file. However, Diffstat assumes that the generated program uses the same command-line options, such as "- c", to extract to standard output.
DIFFSTAT_BZCAT_PATH
DIFFSTAT_BZIP2_PATH
DIFFSTAT_COMPRESS_PATH
DIFFSTAT_GZIP_PATH
DIFFSTAT_LZCAT_PATH
DIFFSTAT_PCAT_PATH
DIFFSTAT_UNCOMPRESS_PATH
DIFFSTAT_ZCAT_PATH
4. Examples
Statistical difference information
[root@localhost wj] # diff 1.c 2.c
1c1
< asd --- >Add
3,4c3,4
< dfg < ass --- >Dsgf
> sss
[root@localhost wj] # diff 1.c 2.c | diffstat-f 2
Unknown | 6 + +--
1 file changed, 3 insertions (+), 3 deletions (-)
[root@localhost wj] # diff 1.c 2.c | diffstat-f 1
Unknown | 6 + +--
1 file changed, 3 insertions (+), 3 deletions (-)
You have new mail in / var/spool/mail/root
[root@localhost wj] # diff 1.c 2.c | diffstat-f 0
Unknown | 6 3 + 3-0!
1 file changed, 3 insertions (+), 3 deletions (-)
[root@localhost wj] #
This is the end of the introduction to "the usage of the Linux basic command diffstat". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.