Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 85343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:04:28+00:00 2026-05-10T22:04:28+00:00

I have a file with n lines. (n above 100 millions) I want to

  • 0

I have a file with n lines. (n above 100 millions)

I want to output a file with only 1 of 10 lines, I can’t split the file in ten part and keep only one part, as it must be a little more random. later I have to do a statistical analysis I can’t afford to create a strong bias in the data).

I was thinking of reading the file and for each record if the record number mod 10 then output it.

The constraints are:

  • it’s a windows (likely hardened) computer possibly XP Vista or Windows server 2003.

  • no development tools available

  • no network,usb,cd-rom. read no external communication.

Therefore I was thinking of windows batch file (I can’t assume powershell, and vbscript is likely to have been removed). And at the moment looking at the FOR /F command. Still I am not an expert and I don’t know how to achieve this.

Thank you Paul for your answer. I reformat (with Hosam help) the answer to put it in a batch file:

@echo off setlocal    findstr/N . inputFile| findstr ^[0-9]*0: >temporaryFile FOR /F 'tokens=1,* delims=: ' %%i in (temporaryfile) do echo %%j > outputFile 

Thanks quux and Pax for the similar alternative solution. However after a quick test on a larger file Paul’s answer is roughly 8 times faster. I guess the evaluation (in SET) is kind of slow, even if the logic seems brilliant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:04:29+00:00Added an answer on May 10, 2026 at 10:04 pm

    Ok, I think I’ve cracked it:

    findstr/N . path-to-log-file | findstr ^[0-9]*0: 

    (use findstr to add the line number to the beginning of the line, then again to print only lines with a line number ending in zero)

    So you’ll get one line in 10, but with the linenumber and colon prepended to each line

    If I can think of a way using command-line tools only of stripping that out, I’ll edit this answer 🙂

    Remove the line number and colon with

    FOR /F 'tokens=1,2* delims=: ' %i in (file-with-linenumbers) do echo %j 

    Paul.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer row = $('body').find('#' + row_id); More importantly doing the additional… May 11, 2026 at 12:48 pm
  • added an answer Go to Tools->Options->Text Editor->C#->General and check 'Navigation Bar' May 11, 2026 at 12:48 pm
  • added an answer The chr() function returns a character given by the integer… May 11, 2026 at 12:48 pm

Related Questions

I have a file with fields separated by pipe characters and I want to
I have a file with data listed as follows: 0, 2, 10 10, 8,
I have a file with a bunch of lines. I have recorded a macro
I have a file with a little over a million lines. {<uri::rdfserver#null> <uri::d41d8cd98f00b204e9800998ecf8427e> <uri::TickerDailyPriceVolume>
I have a CSV file that holds about 200,000 - 300,000 records. Most of
I decide to learn more about vim and its syntax highlighting. Using examples for
First post, so here goes. I'm writing a script that does intelligent search and
Say I have a file with any number of lines, say, 125. I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.