当前位置:网站首页>Common text processing tools
Common text processing tools
2022-07-07 12:57:00 【LC181119】
1. File content view command
1.1 View the contents of the text file
1.1.1 cat
cat You can view the text content
Format :
cat [OPTION]... [FILE]...
Common options :
- -E: Show line end symbol $
- -A: Show all controls
- -n: Number each line shown
- -b: Non empty line number
- -s: Compress consecutive empty lines into one line
1.1.2 nl
According to the line Numbers , amount to cat -b
1.1.3 tac
Reverse display text content
1.1.4 rev
Reverse the contents of the same line
1.2 View non text file content
1.2.1 hexdump
1.2.2 od
1.2.3 xxd
2. View the contents of the file in pages
2.1 more
Can achieve paging view file , It can be used to paginate the output information with the pipeline
Format
more [OPTIONS...] FILE...
Options :
- -d: Display page turning and exit display
2.2 less
less You can also view files or STDIN Output ,less The order is man The pager used by the command
Useful commands for viewing include :
/ Text Search for Text
n/N Skip to the next or Last match
3. Show text before or after line
3.1 head
You can display the front line of a file or standard input
Format :
head [OPTION]... [FILE]...
Options :
- -c # Specify before getting # byte
- -n # Specify before getting # That's ok ,# If it's negative , It means to get the penultimate from the file header # front
- -# ditto
3.2 tail
tail and head contrary , The standard input file or the inverted line view
Format :
tail [OPTION]... [FILE]...
Common options :
- -c # After specifying acquisition # byte
- -n # After specifying acquisition # That's ok , If # It's a negative number , Says from the first # From the beginning of the line to the end of the file
- -# ditto
- -f Trace display file fd New additions , Common log monitoring , amount to --follow=descriptor, When a file is deleted, a new file with the same name is created , Will not be able to continue tracking files
- -F Trace filename , amount to --follow=name --retry, When the file is deleted, create a file with the same name , Will be able to continue tracking files
- tailf similar tail -f, Don't access files when they don't grow , Saving resource ,centos8 No such tool
4. Extract text by column cut
cut [OPTION]... [FILE]...
Common options :
- -d DELIMITER: Indicates the separator , Default tab
- -f FILEDS:
#: The first # A field , for example :3
#,#[,#]: Discrete multiple fields , for example :1,3,6
#-#: Continuous multiple fields , for example :1-6
A mixture of :1-3,7
- -c Cut by character
- --output-delimiter=STRING Specify output separator
5. Merge multiple files paste
paste [OPTION]... [FILE]...
- -d # Separator : Specify the separator , The default with TAB
- -s # All rows are merged into one row to display
6. Tools for analyzing text
6.1 Collect text Statistics wc
- -l Just count the number of lines
- -w Just count the total number of words
- -c Count only the total number of bytes
- -m Count only the total number of characters
- -L Displays the length of the longest line in the file
6.2 Text sorting sort
sort [options] file(s)
- -r Execute in the opposite direction ( From top to bottom ) Arrangement
- -R Stochastic ranking
- -n Perform sorting by number
- -h Human readable sequencing , Such as : 2K 1G
- -f Option ignored (fold) The case of characters in a string
- -u Options ( unique ,unique), Merge duplicates , That is to say, to remove the weight
- -t c Option to use c As a field qualifier
- -k # Options according to use c Character separated # Column can be used more than once
6.3 duplicate removal uniq
uniq [OPTION]... [FILE]...
- -c: Shows how many times each line repeats
- -d: Show only repeated lines
- -u: Show only lines that have not been repeated
6.4 Compare files
6.4.1diff
-u Option to output “ A unified (unified)”diff Format file , Best for patch files
6.4.2 patch
-b Option to automatically back up changed files
6.4.3 vimdiff
6.4.4 cmp
边栏推荐
猜你喜欢
【无标题】
NPM instal reports agent or network problems
[statistical learning methods] learning notes - Chapter 5: Decision Tree
Day-15 common APIs and exception mechanisms
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
- Oui. Migration entièrement automatisée de la Sous - base de données des tableaux d'effets sous net
Multi row and multi column flex layout
Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion
Common knowledge of one-dimensional array and two-dimensional array
Master公式。(用于计算递归的时间复杂度。)
随机推荐
What kind of methods or functions can you view the laravel version of a project?
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
HZOJ #235. 递归实现指数型枚举
免费手机号码归属地API查询接口
[crawler] avoid script detection when using selenium
HZOJ #236. Recursive implementation of combinatorial enumeration
What are the benefits of ip2long?
【无标题】
mysql怎么创建,删除,查看索引?
Layer pop-up layer closing problem
通讯协议设计与实现
Realize a simple version of array by yourself from
数据库安全的重要性
Four functions of opencv
Guangzhou held work safety conference
Leetcode brush questions: binary tree 19 (merge binary tree)
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
通过Keil如何查看MCU的RAM与ROM使用情况
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion