标题: [文本处理] 批处理如何提取含特定字符的行? [打印本页]
作者: anjohnlee 时间: 2014-10-13 08:34 标题: 批处理如何提取含特定字符的行?
各位大神,我有一段文本如下,想提取所有含字符“>”的行到另一个文本中
>gi|156339812|ref|XP_001620269.1| hypothetical protein NEMVEDRAFT_v1g148627 [Nematostella vectensis]
QELDELLEEEKLIGVPLLVFANKQDLMNAATPAEISSNLGLNTIRSRGWQIQGCSALTGEGVQVSL
>gi|290995306|ref|XP_002680236.1| predicted protein [Naegleria gruberi]
MLVIWANKQDLPNAVVDVDELTKILQLNSIKQTSYIQPCSAVRGTGLYEGLEWISNNL
>gi|677097050|gb|KFP32535.1| ADP-ribosylation factor-like 5A, partial [Colius striatus]
DLKKAGLLIFANKQDVKECMTVAEISQFLKLTSIKDHQWHIQACCALTGEGLCQGLE
>gi|290995306|ref|XP_002680236.1| predicted protein [Naegleria gruberi]
MLVIWANKQDLPNAVVDVDELTKILQLNSIKQTSYIQPCSAVRGTGLYEGLEWISNNL
>gi|537203262|gb|ERE79577.1| ADP-ribosylation factor-like protein 3 [Cricetulus griseus]
MVQELTELLEEEKLSCVPVLIFANKQDLLTAAPASEIAEGLNLHTIRDRVWQIQSCSALTGEGVQDGMNWVCKNVNAKKK
即,提取下文中的五行,求大神动动手指教教我啊
>gi|156339812|ref|XP_001620269.1| hypothetical protein NEMVEDRAFT_v1g148627 [Nematostella vectensis]
>gi|290995306|ref|XP_002680236.1| predicted protein [Naegleria gruberi]
>gi|677097050|gb|KFP32535.1| ADP-ribosylation factor-like 5A, partial [Colius striatus]
>gi|290995306|ref|XP_002680236.1| predicted protein [Naegleria gruberi]
>gi|537203262|gb|ERE79577.1| ADP-ribosylation factor-like protein 3 [Cricetulus griseus]
作者: jian123ch 时间: 2014-10-13 09:16
下面的代码我是在WIN7下调试通过的。- @echo off
- setlocal enabledelayedexpansion
- (for /f "eol= delims=" %%i in (testbbs1.txt) do (
- set strtmp=%%i
- if "!strtmp:~0,1!"==">" (echo !strtmp!)
- ))>newtext.txt
- type newtext.txt
复制代码
作者: xudaweb 时间: 2014-10-13 09:20
- findstr ">gi|" 1.txt >>2.txt
复制代码
作者: jian123ch 时间: 2014-10-13 09:22
回复 3# xudaweb
“findstr”这个命令,我还没有学到!
作者: 522235677 时间: 2014-10-13 13:18
- findstr ">" 1.txt >new.txt
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |