Skip to main content

Command Palette

Search for a command to run...

Cheat Sheet #day60 - cmp

Updated
2 min read
Cheat Sheet #day60 - cmp

cmp Command Cheatsheet

The cmp command in Unix-like systems is used to compare two files byte by byte. It is useful for finding the first difference between two files. Here’s a quick reference guide:

Basic Syntax

cmp [OPTION]... FILE1 FILE2

Common Options

  • -b, --print-bytes: Output differing bytes in decimal format.

      cmp -b file1.txt file2.txt
    
  • -i POS, --ignore-initial=POS: Ignore the first POS bytes of each file.

      cmp -i 10 file1.txt file2.txt
    
  • -l, --line-by-line: Output the byte number and the differing bytes.

      cmp -l file1.txt file2.txt
    
  • -s, --silent, --quiet: Suppress all output, only return exit status.

      cmp -s file1.txt file2.txt
    
  • -v, --verbose: Output a message when files differ.

      cmp -v file1.txt file2.txt
    

Examples

  1. Compare two files and print the first difference:

     cmp file1.txt file2.txt
    
  2. Compare files byte by byte and print differing bytes in decimal format:

     cmp -b file1.txt file2.txt
    
  3. Ignore the first 10 bytes and compare the rest of the files:

     cmp -i 10 file1.txt file2.txt
    
  4. Output the byte number and differing bytes:

     cmp -l file1.txt file2.txt
    
  5. Silent comparison, only return exit status:

     cmp -s file1.txt file2.txt
    
  6. Verbose output when files differ:

     cmp -v file1.txt file2.txt
    

Additional Information

  • Help option:

      cmp --help
    
  • View cmp manual page:

      man cmp
    

This cheatsheet covers the essential options and usage scenarios for the cmp command. For more detailed information, refer to the man page or use cmp --help.

B

I want to share my sincere belief in Catherine E. Russell on Facebook as an outstanding trading manager. Catherine's intelligence and wealth of experience make her one of the best in the industry. It's understandable to have reservations with the amount you have, but I assure you, Catherine is not only trustworthy but also incredibly helpful and truthful.By following her guidelines, you'll discover a world of profitable opportunities. Catherine offers the best signals and trading experiences, ensuring that every step you take is guided towards success. Trust in her expertise and let's embark on a journey where regret has no place.

Cheat Sheets

Part 1 of 50

These cheat sheets are designed to be quick reference materials, offering condensed information, tips, and best practices in a easy to understand format.

More from this blog

Cloud Tuned

629 posts

Your starting point for anything cloud: AWS, Azure, GCP, Serverless, Architecture, Hybrid Cloud, Systems Design and other Information Technology topics.