博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Test2 unit6
阅读量:6970 次
发布时间:2019-06-27

本文共 1249 字,大约阅读时间需要 4 分钟。

 unit6


1.diff,patch命令

  diff -c file file1                      ##查看上下文周围的行

diff -u file file1 > file.path             ##补丁

yum install patch -y                      ##安装打补丁工具

patch -b file file.path                   ##备份file

  patch file file.path                          ##给file打补丁

  2.grep命令

grep root passwd                                ##查找字符root

grep -i test passwd                             ##查找忽略大小写

 


grep -n test passwd                            

grep -c test passwd                           

grep -v -i test passwd                         ##反向查找

grep -E “root|test” passwd               ##查找“”中字符

grep -i test -r /mnt/                     ##递归查找目录里的字符

grep ^root passwd                        ##查找在行首的字符

grep root$ passwd                        ##查找在行尾的字符

grep -i test passwd | grep -v -i -E "^tset|test$"  ##查找在不在行首行尾的字符


3.cut 命令

cut -d : -f 1 passwd                             ##-d指定分隔符 -f指定字段

cut -c 2-5 passwd                                ##-c 指定文本列


4.sort,uniq命令

sort -n test                                     ##按升序排列

sort -run test                                    ##按降序排列


sort -t : k 1 -run test                          ##-t指定分隔符 k指定字段

sort -rn test | uniq -u                             ##显示唯一行

sort -rn test | uniq -d                            ##显示重复行

    

sort -rn test | uniq -c                            ##统计行数

5.tr 命令

tr 'a-z''A-Z'  <file                        ##小写大写

tr 'A-Z' 'a-z' <file                               ##大写变小写

 6.sed 命令

sed ‘s/root/westos/g’ passwd                                 ##将文件内root换成westos

 

sed ‘s/root/westos/g’-i passwd                                  ##将结果输入到文件

sed -e‘s/root/westos/g’ -e 's/nologin/west/g' passwd  ##同时转换两个字符

sed 5d westos                                            ##隐藏第5行

 

sed 5p westos                                         ##重复第5行

sed ‘3,5s/root/westos/g’ passwd                    ##把3-5行的root换为westos


sed -n 5p westos   ##单独列出第五行

sed -ne 2p -ne 4p westos   ##列出第二行和第四行

本文转自 漂浮的天堂  51CTO博客,原文链接:http://blog.51cto.com/12774215/1922085,如需转载请自行联系原作者
你可能感兴趣的文章
mac开启Airdrop的硬件要求
查看>>
JAVA异常处理相关面试题
查看>>
遍历Map集合的几种方法
查看>>
pg数据库忘记密码
查看>>
209. Minimum Size Subarray Sum
查看>>
面面观 | CentOS install etcd 测试
查看>>
C#之选择排序
查看>>
MGR架构~MGR+proxysql(1)
查看>>
Leetcode | Next Permutation
查看>>
Delphi动态事件深入分析
查看>>
IntelliJ IDEA 14 注册码
查看>>
threadid=1: thread exiting with uncaught exception (group=0x417cce00)问题
查看>>
[CF566A]Matching Names
查看>>
Clairaut 定理 证明
查看>>
SQL获取当前日期的年、月、日、时、分、秒数据
查看>>
页面优化
查看>>
视频直播技术详解:直播的推流调度
查看>>
js的介绍
查看>>
JavaScript数据类型
查看>>
Emacs 番茄钟 pomidor
查看>>