当前位置:网站首页>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
边栏推荐
- What if the xshell evaluation period has expired
- [statistical learning method] learning notes - support vector machine (I)
- Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)
- 2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
- 【从 0 开始学微服务】【01】什么是微服务
- 【无标题】
- 事务的七种传播行为
- 博文推荐|Apache Pulsar 跨地域复制方案选型实践
- How does MySQL create, delete, and view indexes?
- Adopt a cow to sprint A shares: it plans to raise 1.85 billion yuan, and Xu Xiaobo holds nearly 40%
猜你喜欢
Day-14 common APIs
图形对象的创建与赋值
How to apply @transactional transaction annotation to perfection?
leetcode刷题:二叉树21(验证二叉搜索树)
《ASP.NET Core 6框架揭秘》样章[200页/5章]
Cookie
[crawler] avoid script detection when using selenium
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
Blog recommendation | Apache pulsar cross regional replication scheme selection practice
[statistical learning method] learning notes - support vector machine (Part 2)
随机推荐
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
leetcode刷题:二叉树19(合并二叉树)
详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
[learn microservice from 0] [01] what is microservice
test
How to apply @transactional transaction annotation to perfection?
【二叉树】删点成林
Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
What if the xshell evaluation period has expired
Adopt a cow to sprint A shares: it plans to raise 1.85 billion yuan, and Xu Xiaobo holds nearly 40%
Connect to blog method, overload, recursion
Image pixel read / write operation
如何将 @Transactional 事务注解运用到炉火纯青?
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
谷歌浏览器如何重置?谷歌浏览器恢复默认设置?
HZOJ #240. 图形打印四
ClickHouse(03)ClickHouse怎么安装和部署