001、
(base) [b20223040323@admin1 test]$ ls a.txt b.txt (base) [b20223040323@admin1 test]$ cat a.txt ## 测试数据 GENE=3BHSD 1 1 GENE=A3GALT2 1 1 GENE=A1BG 1 1 GENE=AAAS 1 1 GENE=A1CF 1 1 GENE=A2M 0 0 (base) [b20223040323@admin1 test]$ cat b.txt ## 测试数据 GENE=3BHSD GENE=A1BG GENE=A1CF (base) [b20223040323@admin1 test]$ cp a.txt a.txt_bak ## 对要在源文件中修改的文件进行备份,防止出现意外 (base) [b20223040323@admin1 test]$ for i in $(cat b.txt ); do sed -i "/$i/d" a.txt; done ## 利用循环结构,sed删除匹配字符串的行 (base) [b20223040323@admin1 test]$ ls a.txt a.txt_bak b.txt (base) [b20223040323@admin1 test]$ cat a.txt ## 修改后的结果 GENE=A3GALT2 1 1 GENE=AAAS 1 1 GENE=A2M 0 0
标签:GENE,提取,admin1,test,base,b20223040323,linux,字符串,txt From: https://www.cnblogs.com/liujiaxin2018/p/17223146.html