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 4612460
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:24:21+00:00 2026-05-22T01:24:21+00:00

I have a script that produces a lot of output. The script pauses for

  • 0

I have a script that produces a lot of output. The script pauses for a few seconds at point T.

Now I am using the less command to analyze the output of the script.
So I execute ./script | less. I leave it running for sufficient time so that the script would have finished executing.

Now I go through the output of the less command by pressing Pg Down key. Surprisingly while scrolling at the point T of the output I notice the pause of few seconds again.

The script does not expect any input and would have definitely completed by the time I start analyzing the output of less.

Can someone explain how the pause of few seconds is noticable in the output of less when the script would have finished executing?

  • 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-22T01:24:21+00:00Added an answer on May 22, 2026 at 1:24 am

    Your script is communicating with less via a pipe. Pipe is an in-memory stream of bytes that connects two endpoints: your script and the less program, the former writing output to it, the latter reading from it.

    As pipes are in-memory, it would be not pleasant if they grew arbitrarily large. So, by default, there’s a limit of data that can be inside the pipe (written, but not yet read) at any given moment. By default it’s 64k on Linux. If the pipe is full, and your script tries to write to it, the write blocks. So your script isn’t actually working, it stopped at some point when doing a write() call.

    How to overcome this? Adjusting defaults is a bad option; what is used instead is allocating a buffer in the reader, so that it reads into the buffer, freeing the pipe and thus letting the writing program work, but shows to you (or handles) only a part of the output. less has such a buffer, and, by default, expands it automatically, However, it doesn’t fill it in the background, it only fills it as you read the input.

    So what would solve your problem is reading the file until the end (like you would normally press G), and then going back to the beginning (like you would normally press g). The thing is that you may specify these commands via command line like this:

    ./script | less +Gg
    

    You should note, however, that you will have to wait until the whole script’s output loads into memory, so you won’t be able to view it at once. less is insufficiently sophisticated for that. But if that’s what you really need (browsing the beginning of the output while the ./script is still computing its end), you might want to use a temporary file:

     ./script >x & less x ; rm x
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby script that produces a Latex document using an erb template.
I have a REST service that produces a JSON output. I'm using Jersey. I
I have an script that adds products to a remote database using a RESTful
I have a jquery script that searches a php file that produces an XML
I have a php script that only produces logs to the client. When I
I have a script that I run which does a lot of tasks and
I have a PHP script that produces a .CSV export file from a MySQL
My problem is I have a php script that produces an RSS feed. It
I am given a task where I have this VB.Net script that produces and
I have a script that produces a report. For most widgets* it produces a

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.