Linux text processing

Weaving magic demon 2021-03-27 19:21:35
linux text processing


cat command

cat Commands can be used to display the contents of a text file ( Be similar to DOS Under the type command ), You can also attach the contents of several files to another file , That is to connect and merge files .

Options

meaning

-A

amount to -vET Integration of options , Used to list all hidden symbols ;

-E

List the carriage returns at the end of each line $;

-n

Number all lines of output ;

-b

Same as -n Different , This option means that only non empty lines are numbered .

-T

hold Tab key ^I 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 .

cat file name ------ View text content

cat -n file name ---------- According to the line Numbers .

cat -A file name ---------- View all hidden symbols in the text , Including carriage returns ($)、Tab key (^I) etc.

more command

more The command can display the contents of the text file in pages , Users can read the contents of the document page by page

[root@localhost ~]# 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, clear the screen first and then display the content .

-c

Follow -p Similar options , The difference is to display the content first and then clear 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 -c -10 test.txt Every time 10 Line display one screen , Clear the screen at the same time

head command

head Command to display the contents of a specified file in the first few lines

Options

meaning

-n K

there K Number of lines , This option is used to display the file before K The content of the line ; If you use "-K" As a parameter , In addition to the last part of the file K Out of line , Show all the rest .

-c K

there K Represents the number of bytes , This option is used to display the file before K Bytes of content ; If you use "-K", In addition to the last part of the file K The contents of bytes , Show the rest .

-v

Show filename ;

head The command defaults to the beginning of the file 10 Row content .

Show the beginning of the file 20 Row content

less command

less The function of command and more Very similar , Are used to browse the contents of text files , The difference is , Use more Command to browse the contents of a file , Just keep looking back , While using less Command to browse , You can look back , You can also look forward .

More Than This , In order for users to browse text content ,less The command also provides the following functions :

  • Use the cursor keys to move around in a text file ( Back left ) Scroll ;
  • Use line numbers or percentages as bookmarks to browse files ;
  • Provide more friendly retrieval 、 Highlight and so on ;
  • Compatible with common word processing programs ( Such as Vim、Emacs) Keyboard operation of ;
  • By the end of the reading ,less Orders don't quit ;
  • The information at the bottom of the screen makes it easier to control the use of , And it provides more information .

Options

Meaning of options

-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

Only mark the last key searched .

-Q

Don't use a 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 the size of the buffer .

-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 command

tail Command and head The order is just the opposite , It's used to look at the data at the end of the file , The basic format is as follows :

[root@localhost ~]# tail [ Options ] file name

Options

meaning

-n K

there K It's the number of lines , This option indicates the last K That's ok , On this basis , If you use -n +K, From the second part of the file K Line start output .

-c K

there K It's the number of bytes , This option indicates the last... Of the output file K Bytes of content , On this basis , Use -c +K From the file No K The output starts with two bytes .

-f

New data added after the output file changes .

see At the end of the text 3 The data content of the row .

Original statement , This article is authorized by the author + Community publication , Unauthorized , Shall not be reproduced .

If there is any infringement , Please contact the yunjia_community@tencent.com Delete .

版权声明
本文为[Weaving magic demon]所创,转载请带上原文链接,感谢
https://javamana.com/2021/03/20210316185909558j.html

  1. K8s命令篇-Kubernetes工作实用命令集结号
  2. K8s command chapter - kubernetes working practical command collection number
  3. Hbase(二)Hbase常用操作
  4. San Wai doesn't even know how to change MySQL table DDL
  5. HTTP series - detailed explanation of message structure
  6. MySQL 常见存储引擎的区别
  7. Flink 1.12 集成 Hive 之快速入门
  8. Java - BlockingQueue学习
  9. MySQL 存储引擎 MyISAM 与 InnoDB 区别
  10. Linux three swordsmen (1) - grep
  11. 《算法竞赛入门经典——训练指南》实用数据结构
  12. Practical data structure of "Introduction to algorithm competition classic training guide"
  13. Hive的数据压缩介绍及使用
  14. Redis:23---info命令总结
  15. Redis:23---info Command summary
  16. Quick start kubernetes (k8s) - resource list
  17. Java方法签名
  18. Linux命令4-find、locate
  19. Linux commands 4-find, locate
  20. linuxNote1_用户管理
  21. Brief description of Tencent cloud redis console parameters
  22. Java中正则表达式
  23. MySQL 事务隔离级别和多版本并发控制MVCC
  24. 再见,MySQL!性能被 MariaDB 吊打 ?
  25. Regular expression in Java
  26. Goodbye, MySQL! Performance is being beaten by MariaDB?
  27. Don't download JDK any more: elasticsearch's first big hole in the domestic arm environment
  28. Introduction to MySQL architecture
  29. Linux foundation day02
  30. [javap6 outline] Spring Court: how to select the technology of fuse framework? Sentinel or hystrix?
  31. Chinese user guide of parallel SSH under Linux
  32. Top of BPF: insight into Linux system and application performance
  33. View the JDK version of class
  34. JQuery level selector (descendant, descendant selector)
  35. Interesting JavaScript - precision loss and implicit type conversion
  36. Database: built in functions of MySQL