What are the commands for viewing the contents of a file on a Linux system?

  
                

Linux file content review, you can use the command to achieve. Cat, tac, more, including nl and other commands can be used to view the contents of the file. This article introduces by way of example, what are the commands for the Linux system to view the contents of the file.

/messages at any time the data will be written to the file you want to make the data immediately displayed on the screen, on the use of the -f option when writing, he can always detect /var /log/messages This file, the newly added data will be displayed on the screen. Until you press [crtl]-c, you will leave the detection of tail!

Non-Pure Text File: od

[root@www ~]# od [-t TYPE] File

Option or Parameter:

-t : You can connect to various types of "TYPE" output, for example:

a : use the default byte to output;

c : use ASCII bytes to output

d[size] : Use decimal to output data, each integer occupies size bytes;

f[size] : use floating point value (floating) to output data, each number Occupy size bytes ;

o[size] : Use octal to output data, each integer occupies size bytes;

x[size] :Using hexadecimal To output data, each integer occupies size bytes;

Example 1: Please use the ASCII method to display the contents of /usr/bin/passwd!

[root@www ~]# od -tc /usr/bin/passwd

0000000 177 ELF 001 001 001 \\0 \\0 \\0 \\0 \\0 \\0 \\0 \\0 \\ 0

0000020 002 \\ 0 003 \\ 0 001 \\ 0 \\ 0 \\ 0 260 225 004 \\ b 4 \\ 0 \\ 0 \\ 0

0000040 020 E \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 4 \\ 0 \\ 0 \\ a \\ 0 (\\ 0

0000060 035 \\ 0 034 \\ 0 006 \\ 0 \\ 0 \\ 0 4 \\ 0 \\ 0 \\ 0 4 200 004 \\ b < Br>

0000100 4 200 004 \\b 340 \\0 \\0 \\0 340 \\0 \\0 \\0 005 \\0 \\0 \\0

. . . (omitted later)...

# The first column on the left is the octet to represent the number of bytes. In the above example, the second column 0000020 represents the beginning of

#16th byes (2x8) The meaning of the content.

Example 2: Please list the contents of the /etc/issue file in 8-bit to store the stored value and ASCII comparison table

[root@www ~]# od - t oCc /etc /issue

0000000 103 145 156 164 117 123 040 162 145 154 145 141 163 145 040 065

C ent OS release 5

0000020 056 062 040 050 106 151 156 141 154 051 012 113 145 162 156 145

. 2 (F inal) \\ n K erne

0000040 154 040 134 162 040 157 156 040 141 156 040 134 155 012 012

l \\ ronan \\ m \ \

0000057

# As shown above, you can find out the value that each byte can correspond to!

# For example, e corresponds The recorded value is 145, which is converted to decimal: 1x8^2+4x8+5=101.

Modify the file time or create a new file: touch

modification time (mtime):

When the "content data" of the file changes, it will be upgraded. ! Content data refers to the content of the file, not the attributes or permissions of the file!

status time (ctime):

When the "status" of the file changes, the time is upgraded. For example, permissions and properties are changed. Will upgrade this time.

access time (atime):

When the content of the file is taken, the read time is upgraded. For example, if we use cat to read /etc/man.config , we will upgrade the atime of the file.

By default, ls shows the mtime of the file, which is the time the content of this file was last changed.

[root@www ~]# touch [-acdmt] File Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved