我正在尝试使用Windows批处理脚本将abc.txt的一部分复制到def.txt文件。
的abc.txt
Connected to: Oracle Database 11g Enterprise Edition Release
11.2.0.4.0 - 64bit Production. With the Partitioning, Automatic Storage
Management, OLAP, Data Mining and Real Application Testing options.
About to export specified tables via Conventional Path ...
... exporting table table_1 2000 rows exported
..... exporting table table_2 456512 rows exported
. . exporting table table_3 So on...
Export successful with warnings. table_1 has some issue.
def.txt
Connected to: Oracle Database 11g Enterprise Edition Release
11.2.0.4.0 - 64bit Production. With the Partitioning, Automatic Storage
Management, OLAP, Data Mining and Real Application Testing options.
About to export specified tables via Conventional Path ...
Export successful with warnings. table_1 has some issue.
简而言之,我想跳过具有字符串"导出"的行。并将结果移动到def.txt。我尝试使用for /F
但无法实现这一点。能否请你帮忙。提前谢谢。
答案 0 :(得分:3)
findstr /v /c:"exporting" abc.txt > def.txt
无需迭代文件。只需过滤输入文件中与包含指定文字的条件不匹配(/v
)的行,并将输出发送到指定的文件。
已修改以适应评论
@echo off
setlocal enableextensions disabledelayedexpansion
> def.txt (
for /f "tokens=1,* delims=:. " %%a in ('
findstr /n "^" abc.txt
') do echo(%%b
)
此处文件由findstr
处理以对行进行编号(以保留源文件中的空行),输出由for /f
命令delims
和{{1}处理}子句配置为删除输出行中的起始空格/点/冒号。
答案 1 :(得分:2)
这与MC ND的解决方案没有实际区别 - 但它是另一种选择:它目前区分大小写,但有一个/i
切换来改变它。
find /v "exporting" < abc.txt > def.txt