1、

[root@centos79 test]# cat a.txt
a g r e
u c j alike
i x k like
a f g liker
a f h g liker
s g e g
[root@centos79 test]# grep "^a" a.txt   ## 查找以a开头的行
a g r e
a f g liker
a f h g liker
[root@centos79 test]# grep "^a.*r$" a.txt   ## 同时查找以a开头同时以r结尾的行
a f g liker
a f h g liker
[root@centos79 test]# grep "^a.*h.*r$" a.txt  ## 同时查找以a开头,包含字符h,并以r结尾的行
a f h g liker

 

2、

[root@centos79 test]# cat a.txt
a g r e
u c j alike
i x k like
a f g liker
a f h g liker
s g e g
[root@centos79 test]# grep "^a\|e$" a.txt  ## 提取以a开头,或者以e结尾的行
a g r e
u c j alike
i x k like
a f g liker
a f h g liker

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-02-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案