Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the cmp command in Linux

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to use the cmp command in Linux", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to use the cmp command in Linux" this article.

The cmp command is used to compare whether there are differences between the two files. When the two files compared to each other are exactly the same, the directive does not display any information. If a difference is found, the default will indicate the character and column number of the first difference.

Cmp compares whether there are differences between the two files.

Add that if no file name is specified or given a file name of "-", the cmp instruction will read the data from the standard input device.

Syntax cmp (option) (parameter) option-c or-- print-chars: displays the character corresponding to the character in addition to the decimal code indicating the difference;-I or-- ignore-initial=: specifies a number;-l or-- verbose: marks all differences;-s or-- quiet or-- silent: does not display error message;-v or-- version: displays version information -- help: online help. Parameter directory: compare the differences between two files.

If the instance uses the cmp command to compare the file "testfile" and the file "testfile1", enter the following command:

Cmp testfile testfile1 # compare two specified files before the above instruction is executed, use the cat command to view the contents of the two specified files, as follows:

Cat testfile # View file content Absncn 50 # display file "testfile" Asldssja 60 Jslkadjls 85 cat testfile1 # View file content Absncn 50 # display file "testfile1" AsldssjE 62 Jslkadjls 85 then execute the cmp command and return the comparison result, as shown below:

Cmp testfile testfile1 # compares two files testfile testfile1 # there is a difference: byte 8, line 2 Note: in the comparison result, only the first comparison result can be displayed.

The above is all the contents of the article "how to use cmp commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report