linux中查找包含特定字符的文件
2021/7/5 7:25:07
本文主要是介绍linux中查找包含特定字符的文件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1、测试数据
[root@centos79 test]# ls a.txt [root@centos79 test]# cat a.txt a g e u c j alike i x k like w f g liker s g e g [root@centos79 test]# echo "b.txt c.txt d.txt" | xargs -n 1 cp a.txt [root@centos79 test]# ls a.txt b.txt c.txt d.txt [root@centos79 test]# md5sum * 6659dac6dc59934b85df2f6d08c37e9f a.txt 6659dac6dc59934b85df2f6d08c37e9f b.txt 6659dac6dc59934b85df2f6d08c37e9f c.txt 6659dac6dc59934b85df2f6d08c37e9f d.txt
2、
[root@centos79 test]# ls a.txt b.txt c.txt d.txt [root@centos79 test]# echo "error" >> b.txt [root@centos79 test]# echo "ERROR" >> c.txt [root@centos79 test]# echo "failed" >> d.txt [root@centos79 test]# grep -l "error" *.txt ## 包含“error”的文件 b.txt [root@centos79 test]# grep -L "error" *.txt ## 不包含error的文件 a.txt c.txt d.txt [root@centos79 test]# grep -i -l "error" *.txt ##忽略大小写,列出包含error的文件 b.txt c.txt [root@centos79 test]# grep -i -l -E "error|failed" *.txt ## 忽略大小写,同时列出包含“error和failed”的文件 b.txt c.txt d.txt [root@centos79 test]# grep -i -L -E "error|failed" *.txt ## -L 取反 a.txt
这篇关于linux中查找包含特定字符的文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-04Linux系统上离线升级SSH服务的具体操作步骤-icode9专业技术文章分享
- 2024-06-0600-macOS和Linux安装和管理多个Python版本
- 2024-03-30[译]漫画SELinux概念
- 2024-03-29linux 移动文件
- 2024-03-28linux .so file
- 2024-03-28Linux 磁盘管理
- 2024-03-28Linux学习笔记(十三)磁盘管理(一):磁盘分区
- 2024-03-26linux 创建 文件
- 2024-03-25使用SecureCRT对Linux vim进行颜色设置
- 2024-03-202019-2020-12 20199317 《Linux内核原理与分析》 第十二周作业