1、vi编辑
首先利用 vi filenae 查看文件, 在命令行模式下 使用 :g/string/d 执行命令即可删除含有 string字符串的行 ,其中string为字符串
2、sed
[root@centos7 test2]# seq 15 > a.txt
[root@centos7 test2]# ls
a.txt
[root@centos7 test2]# cat a.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@centos7 test2]# sed '/2/d' a.txt
1
3
4
5
6
7
8
9
10
11
13
14
15
3、grep
[root@centos7 test2]# ls
a.txt
[root@centos7 test2]# cat a.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@centos7 test2]# grep -v "2" a.txt
1
3
4
5
6
7
8
9
10
11
13
14
15
4、awk
[root@centos7 test2]# ls
a.txt
[root@centos7 test2]# cat a.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@centos7 test2]# awk '!/2/{print $0}' a.txt
1
3
4
5
6
7
8
9
10
11
13
14
15
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。