【批處理】使用findstr刪除重複多餘的行

例如一個文本(test.txt)是以下的內容,"analyze memory leak mode:"和"hprof format:JAVA PROFILE 1.0.2"和"file analyze done ",在此文本中屢次重複出現。這三行內容,我如今一行都不想要,即我想刪除此文本中包含此三行內容的行。java

Memory Leak Report 
App Package Name: com.tencent.news
App Version: 4.4.9
File_Name:memoryleak_0/result/leak_2014_11_29_14_03_58.hprof 
analyze memory leak mode:
hprof format:JAVA PROFILE 1.0.2
file analyze done 
com.tencent.news.ui.LoginActivity 0x41f59bf8 
com.tencent.news.ui.MainActivity2 0x418bbf80 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_15_58.hprof 
analyze memory leak mode:
hprof format:JAVA PROFILE 1.0.2
file analyze done 
com.tencent.news.ui.MainActivity2 0x415ec590 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_27_17.hprof 
analyze memory leak mode:
hprof format:JAVA PROFILE 1.0.2
file analyze done 
com.tencent.news.ui.MainActivity2 0x415596a8 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_31_50.hprof 
analyze memory leak mode:
hprof format:JAVA PROFILE 1.0.2
file analyze done 
com.tencent.news.ui.ImageDetailActivity 0x41a35898 
com.tencent.news.ui.CommentFragmentActivity 0x41eb27f0 
com.tencent.news.ui.MainActivity2 0x41c2fa18 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_35_58.hprof 
analyze memory leak mode:
hprof format:JAVA PROFILE 1.0.2
file analyze done 
com.tencent.news.ui.MainActivity2 0x4178f998 
com.tencent.news.ui.MainActivity2 0x41582488

想了想,仍是findstr進行實現。shell

參數:    /V  只打印不包含匹配的行ui

           /C:string    使用指定的文本做爲文字搜索字符串(注意/C後緊跟的冒號)spa

findstr /V /C:"analyze memory leak mode:" /C:"hprof format:JAVA PROFILE" /C:"file analyze done" test.txt>test1.txt

結果展現:code

Memory Leak Report 
App Package Name: com.tencent.news
App Version: 4.4.9
File_Name:memoryleak_0/result/leak_2014_11_29_14_03_58.hprof 
com.tencent.news.ui.LoginActivity 0x41f59bf8 
com.tencent.news.ui.MainActivity2 0x418bbf80 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_15_58.hprof 
com.tencent.news.ui.MainActivity2 0x415ec590 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_27_17.hprof 
com.tencent.news.ui.MainActivity2 0x415596a8 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_31_50.hprof 
com.tencent.news.ui.ImageDetailActivity 0x41a35898 
com.tencent.news.ui.CommentFragmentActivity 0x41eb27f0 
com.tencent.news.ui.MainActivity2 0x41c2fa18 
File_Name:memoryleak_0/result/memoryleak_2014_11_29_14_35_58.hprof 
com.tencent.news.ui.MainActivity2 0x4178f998 
com.tencent.news.ui.MainActivity2 0x41582488
相關文章
相關標籤/搜索