码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 之 grep\head\tail 命令使用(第六章)

时间:2018-05-06 10:36:41      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:linux grep head tail

grep\head\tail 命令使用

test.txt
1
2
3
4
5
6
7
8
9
10
test
liyao
oldboy


grep命令:
1.排除文本内容包括oldbody字符(grep -v 命令排除)
[root@localhost kang]# grep -v "oldboy" test.txt
1
2
3
4
5
6
7
8
9
10
test
liyao

2.只查找文件中包含oldbody字符。

[root@localhost kang]# grep "oldboy" test.txt
oldboy

head头部命令
1.查找文件前5行数据
[root@localhost kang]# head -n 5 test.txt
1
2
3
4
5


tail尾部命令
1.查找文件后面3行数据
[root@localhost kang]# tail -n 3 test.txt #默认后10行
liyao
oldboy

2.tail 动态查看后面
[root@localhost kang]# tail -fn 100 test.txt

Linux 之 grep\head\tail 命令使用(第六章)

标签:linux grep head tail

原文地址:http://blog.51cto.com/12965094/2113091

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!