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

  • SEARCH
  • Home
  • 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 4078588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:41:35+00:00 2026-05-20T17:41:35+00:00

Is there a grep-like tool for windows where I can restrict the number of

  • 0

Is there a grep-like tool for windows where I can restrict the number of characters it outputs in a line where a searched for pattern is found.

One of the upstream software systems generates huge text files which we then feed as the input to our system.

Sometimes the input files get corrupted and I need to do a quick textual search to find if particular the bits of data are missing or not. To make it even worse – the input files is just one very very long line of text – and when I use grep or findstr – the result of the search is huge chunk of text.

I am wandering – how can I limit the number of characters grep to show before/after the pattern I searched for.

Cheers.

  • 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. Editorial Team
    Editorial Team
    2026-05-20T17:41:36+00:00Added an answer on May 20, 2026 at 5:41 pm

    Two things spring to my mind:

    • Call grep with the --only-matching option so that only the text that matches is emitted. Depending on your regex, this may or may not help.
    • Write a very simple executable, call it trunc, which reads from stdin line by line and output the first n characters to stdout. Then simply pipe the output from grep to trunc.

    The latter option is relatively simple. If you didn’t want to go the whole hog and produce a proper native exe it could be quite easily achieved with a Perl/Python/Ruby etc. script.

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

Sidebar

Related Questions

Is there a tool like tcpflow for windows? I need to sniff tcp's data
I would like to use the linux command line tool ack but there is
Is there an easy way using grep (or combine with other standard command line
Using only grep and sed, is there a way I can tranform the output
If I want to essentially grep every line ever in the repository, is there
I have a large file of regular expressions, one per line. I would like
Is there any way to list 'per-file' results neatly using grep. Something like: $grep
In eshell, one of the nice things is commands like grep's output will be
In K&R Section 5.10, in their sample implementation of a grep -like function, there
There is no utilites like find, grep , ls -laR to find files in

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.