Delete # of random lines from .txt

April 1, 2009 at 06:34:35
Specs: Windows XP
I have a text file that i'm required to delete certain number of lines randomly. Is there any .bat file for me to do that?

Thanks!


See More: Delete # of random lines from .txt

Report •


#1
April 2, 2009 at 02:51:35
Not clear. Is it a "certain number" or is it random?


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
April 2, 2009 at 05:44:35
It's a pseudo random number!

Report •

#3
April 2, 2009 at 19:42:31
if you can download gawk for windows(see my sig for link)

C:\test>more file.txt
line 1
line 2
line 3
line 4
line 5

C:\test>gawk "BEGIN{srand()}FNR==NR{++d;n=int(rand()*d)+1;next}FNR!=n" "file.txt" "file.txt"
line 1
line 2
line 3
line 5

Unix Win32 tools | Gawk for Windows


Report •

Related Solutions


Ask Question