File 使用文件批处理脚本中的特定字符串跳过行
我正在尝试使用windows批处理脚本将abc.txt的一部分复制到def.txt文件 abc.txtFile 使用文件批处理脚本中的特定字符串跳过行,file,batch-file,for-loop,File,Batch File,For Loop,我正在尝试使用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 optio
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.
简而言之,我想跳过包含字符串“exporting”的行,并将结果移动到def.txt。我尝试将用于/F
,但未能实现此目的。你能帮忙吗。提前谢谢
findstr /v /c:"exporting" abc.txt > def.txt
不需要对文件进行迭代。只需过滤输入文件中与(/v
)包含指示文字的条件不匹配的行,并将输出发送到指示文件
编辑以适应评论
@echo关闭
setlocal enableextensions disabledelayedexpansion
>def.txt(
对于/f“tokens=1,*delims=:。”%%a in('
findstr/n“^”abc.txt
“)做回显(%%b
)
在这里,文件由findstr
处理,以对行进行编号(在源文件中保留空行),输出由for/f
命令处理,其中delims
和tokens
子句配置为删除输出行中的起始空格/点/冒号
无需迭代文件。只需过滤输入文件中与(/v
)包含指示文字的条件不匹配的行,然后将输出发送到指示文件
编辑以适应评论
@echo关闭
setlocal enableextensions disabledelayedexpansion
>def.txt(
对于/f“tokens=1,*delims=:。”%%a in('
findstr/n“^”abc.txt
“)做回显(%%b
)
这里,文件由
findstr
处理,以对行进行编号(在源文件中保留空行),由带有delims
和tokens
子句的for/f
命令处理的输出,这些子句配置为删除输出行中的起始空格/点/冒号。这与MC ND的解决方案没有明显的区别-不过这是另一个选项:它目前区分大小写,但有一个/i
开关来更改t帽子
find /v "exporting" < abc.txt > def.txt
find/v“exporting”def.txt
这与MC ND的解决方案并没有明显的区别-不过这是另一种选择:目前它区分大小写,但有一个/i
开关来改变这一点
find /v "exporting" < abc.txt > def.txt
find/v“exporting”def.txt
谢谢你的回答。findstr/v非常适合我。但是如果我想单独删除点“…”而不考虑abc.txt中的点数。有办法吗?谢谢你的回答。findstr/v非常适合我。但是如果我想单独删除点“…”不管abc.txt中有多少个点。有办法吗?谢谢你的回答。findstr/v非常适合我。但是如果我想单独删除点“…”不管abc.txt中有多少个点。有办法吗?@SwaroopNarasimha,如果你只想删除点,那么你需要迭代文件。请参阅更新的答案。谢谢你的答案。findstr/v非常适合我。但是如果我想单独删除点“…”不管abc.txt中有多少个点。有办法吗?@SwaroopNarasimha,如果您只想删除这些点,则需要迭代文件。请参阅更新的答案。