编程知识 cdmana.com

Linux system file viewing command

cat Display file contents

  • Command format

cat 	[ Options ]	 file name 

​cat		 file 1	 file 2  >  file 3
Options meaning
-A The user lists all hidden symbols in the file , It's equivalent to using -vET Options
-E List the carriage returns at the end of each line $
-n Number all output lines
-b Line to line
-T hold Tab key ^| Show it
-V List special characters
-s When it comes to continuous 2 A blank line above the line , Just replace it with 1 Blank lines of lines

more Display text file , You can read the contents of the file line by line

  • Command format

    more [ Options ] file name

    Options meaning
    -f When calculating the number of lines , In the actual number of lines , Instead of the number of lines after the wrap
    -p Don't scroll through each page , Instead, first clear the screen and then display the content
    -c Follow -p Similar options , The difference is that the content is displayed first before clearing other old data
    -s When there are more than two consecutive blank lines , Just replace it with a blank line
    -u Don't show quotes ( According to environment variable TERM Different from the specified terminal )
    +n From n Line starts to show the contents of the file ,n On behalf of the digital
    -n The number of lines displayed at one time ,n On behalf of the digital

​ more Command interaction instructions and functions

Interactive instruction function
h or ? Show more Command interaction command help
q or Q sign out more
v Start an editor on the current line
:f Displays the file name and line number of the current file
!< command > or :!< command > In the child shell Execute command in
Enter key Move one line down
Space bar Move down one page
ctrl+l The refresh screen
= Displays the line number of the current line
ctrl+f Scroll down one page
. Repeat the last output command
d Move down half a page
b Move a page up

head Displays the file contents of the first few lines of the specified file

  • Command format

    head [ Options ] file name

Options meaning
-n K there K Number of lines , This option is used to display the file before K The content of the line ;
-c K there K Represents the number of bytes , This option is used to display the file before K Bytes of content
-v Show filename

less The functions and more be similar , The difference is ,less The command can look back , You can also look forward

  • Command format

    less [ Options ] file name

Options meaning
-N Show the line number of each line
-S If the line is too long, the excess will be discarded
-e When the file display is finished , Leave automatically
-g Mark only the last key name searched
-Q Not applicable warning tone
-i Ignore case when searching
-m The display is similar to more Percentage of orders
-f Force to open special files , For example, peripheral device code 、 Directories and binaries
-s Show a row of consecutive empty actions
-b < Buffer size > Set buffer size
-o < file name > take less Save the output to the specified file
-x < Numbers > take tab Key is displayed as the specified number space

​ less Interactive instructions and functions

Interactive instruction function
/ character string Search down “ character string ” The function of .
? character string Search up “ character string ” The function of .
n repeat * The previous search ( And / become ? of ).
N Repeat the previous search in reverse ( And / or ? of ).
b Move a page up .
d Move down half a page .
h or H Show help screen .
q or Q sign out less command .
y Move a line up .
Space bar Move down one page .
Enter key Move one line down .
【PgDn】 key Move down one page .
【PgUp】 key Move a page up .
Ctrl+f Move down one page .
Ctrl+b Move a page up .
Ctrl+d Move down one page .
Ctrl+u Move half a page up .
j Move one line down .
k Move a line up .
G Move to the last line .
g Move to first line .
ZZ sign out less command .
v Edit the current file using the configured editor .
[ Move to the previous node in this document .
] Move to the next node in this document .
p Move to the previous node in the same level .
u Move half a page up .

tail Look at the data at the end of the file

  • Command format

    tail [ Options ] file name

    Options meaning
    -n Number of rows , On this basis, if -n Row number , From the second part of the file n Line start output
    -c Refers to the number of bytes , On this basis, if -c Number of bytes , From the second part of the file n The number of bytes starts to output
    -f New data added after the output file changes .

版权声明
本文为[Li Zexin]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/134/202205141347347043.html

Scroll to Top