001、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试数据 NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2 [root@PC1 test]# grep "_[0-9]$" a.txt ## 匹配末尾为_数字的数据,进匹配了一次 NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2
002、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2 [root@PC1 test]# grep "_[0-9]\+" a.txt ## 匹配末尾_加数字一次以上 NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2
003、
[root@PC1 test]# cat a.txt NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2 [root@PC1 test]# grep "_[0-9]\{2\}$" a.txt ## 指定匹配次数为2次 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 [root@PC1 test]# grep "_[0-9]\{3\}$" a.txt ## 指定匹配次数为3次 NC_052532.1 tRNAscan-SE TRNAD-GUC_229
004、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2 [root@PC1 test]# grep "_[0-9]\{2\}$" a.txt ## 匹配两次 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 [root@PC1 test]# grep "_[0-9]\{2,\}$" a.txt ## 匹配数字至少两次 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12
005、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2 [root@PC1 test]# grep "_[0-9]\{,2\}$" a.txt ## 匹配至多为两次 NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_45 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4 NC_052532.1 tRNAscan-SE TRNAI-AAU_2
006、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt NC_052532.1 tRNAscan-SE TRNAD-GUC_1 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_1 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAS-AGA_3 NC_052532.1 tRNAscan-SE TRNAS-AGA_453344 NC_052532.1 tRNAscan-SE TRNAI-AAU_12 NC_052532.1 tRNAscan-SE TRNAD-GUC_3 NC_052532.1 tRNAscan-SE TRNAD-GUC_4325635 NC_052532.1 tRNAscan-SE TRNAI-AAU_2 [root@PC1 test]# grep "_[0-9]\{2,5\}$" a.txt ## 匹配至少为2次,至多为5次 NC_052532.1 tRNAscan-SE TRNAD-GUC_229 NC_052532.1 tRNAscan-SE TRNAS-AGA_27 NC_052532.1 tRNAscan-SE TRNAI-AAU_12
标签:052532.1,匹配,NC,AGA,TRNAS,tRNAscan,linux,grep,SE From: https://www.cnblogs.com/liujiaxin2018/p/17097352.html