chr*_*ome 70 string batch-file
我有一个生成的txt文件.此文件具有某些多余的行,需要删除.需要删除的每一行都有一行中的两个字符串; "错误"或"参考".这些令牌可能出现在该行的任何位置.我想删除这些行,同时保留所有其他行.
所以,如果txt文件看起来像这样:
Good Line of data bad line of C:\Directory\ERROR\myFile.dll Another good line of data bad line: REFERENCE Good line
我希望文件最终像这样:
Good Line of data Another good line of data Good line
TIA.
pax*_*blo 100
使用以下内容:
type file.txt | findstr /v ERROR | findstr /v REFERENCE
这样做的好处是可以在Windows操作系统中使用标准工具,而不必查找和安装sed/awk/perl等.
请参阅以下操作脚本:
C:\>type file.txt Good Line of data bad line of C:\Directory\ERROR\myFile.dll Another good line of data bad line: REFERENCE Good line C:\>type file.txt | findstr /v ERROR | findstr /v REFERENCE Good Line of data Another good line of data Good line
Ric*_*ick 41
您只需使用findstr就能完成与@ paxdiablo相同的解决方案.无需将多个命令组合在一起:
findstr /V "ERROR REFERENCE" infile.txt > outfile.txt
这是如何工作的细节:
如果你有sed:
sed -e'/ REFERENCE/d'-e'/ ERROR/d'[FILENAME]
其中FILENAME是包含好行和坏行的文本文件的名称