Implementation of Linux under OD-TX-TC xxx function

Source: Internet
Author: User

Implementation of Linux under OD-TX-TC xxx function one, od command (1) function

The OD command is used to display the specified file contents in eight-, decimal, 16-, floating-point, or ASCII-encoded characters, and is typically used to display or view characters in a file that cannot be displayed directly in the terminal.

Common files are text files and binary files. The OD command is used primarily to view the values stored in a binary file, interpret the data in the file in the specified format, and output it.

(2) command format

od [<选项><参数>] [<文件名>]

(3) Command options

-t<TYPE>: Specify the output format, including a, C, D, F, O, U, and X, meaning the following:

    • A: a name character;
    • C:ascii characters or backslash;
    • D[size]: decimal, positive negative numbers are included, SIZE bytes form a decimal integer;
    • F[size]: Floating point, SIZE byte consists of a floating-point number;
    • O[size]: octal, SIZE byte consists of an octal number;
    • U[size]: Unsigned decimal, contains only positive numbers, and SIZE bytes form an unsigned decimal integer;
    • X[size]: 16 binary, size byte is the hexadecimal output, which is the output when a column contains a SIZE byte. By default, a set of four bytes of output
Second, the problem analysis

od -tx Fileis to output the contents of file in hexadecimal, which is displayed as a group of four bytes by default.

od -tc FileASCII value corresponding to output byte

In the title, the output od -tx -tc File byte corresponds to the ASCII value, which differs from the order of the output when the file content is output in hexadecimal. od -tc -tx File

Third, Myod.java
Import java.io.*;p ublic class myod{public static void Main (string[] args) throws IOException {try (fileinputst            Ream input = new FileInputStream ("/home/darkeye/cxgg20165312/20165312/hello")) {byte[] data = new byte[1024];            int i, flag;            Input.read (data);  for (i = 0; i < 1024x768; i = i + 4) {if (i% = = 0) {System.out.printf ("\n%07o\t\t",                i); }//Four bytes in one group and four groups in a row.                I=16 is the first column on the left (the default address), formatted as a seven-bit octal. By finding the rule, its value is the octal number corresponding to the ordinal value of the first character of the line (from 0 to length-1) System.out.printf ("%02x%02x%02x%02x\t", Data[i + 3], data[i                + 2], Data[i + 1], data[i]);                    if ((i + 4)% = = 0) {System.out.println ();                    System.out.printf ("\ t"); for (int j = i-12; J < I+4; J + +) {if (int) data[j] = =) {Syst                            em.out.printf ("\ \"); System.out.printf ("n ");                        } else {System.out.printf ("%c", Data[j]);                    }}} if (Data[i+4] ==0) {System.out.println ();                    System.out.printf ("\ t"); for (int j = i-i%16; data[j-3]! = 0; j + +) {if (int) data[j] = =) {S                            ystem.out.printf ("\ \");                        System.out.printf ("n");                        } else {System.out.printf ("%c", Data[j]);                }} break;        }} System.out.printf ("\n%07o\n", i+3); }    }}

Implementation of Linux under OD-TX-TC xxx function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.