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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:17:24+00:00 2026-05-27T15:17:24+00:00

The output of top command in Linux like bellow: Tasks: 158 total, 1 running,

  • 0

The output of top command in Linux like bellow:

Tasks: 158 total, 1 running, 157 sleeping, 0 stopped, 0 zombie
Cpu(s): 6.3%us, 3.2%sy, 0.0%ni, 89.9%id, 0.2%wa, 0.0%hi, 0.2%si,
0.0%st Mem: 8264212k total, 2637492k used, 5626720k free, 299884k buffers Swap: 4192924k total, 0k used, 4192924k free,
2010332k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7178 mysql 15 0 52876 31m 4680 S 21.3 0.4 308:12.04 mysqld
2262 www 16 0 28092 11m 4764 S 4.0 0.1 2:02.31 php-cgi
2110 www 16 0 27956 11m 4888 S 3.7 0.1 2:04.51 php-cgi
2005 www 16 0 28680 12m 4872 S 3.0 0.2 2:04.10 php-cgi
1955 www 16 0 28476 12m 5220 S 2.7 0.1 2:06.51 php-cgi
2030 www 16 0 28260 11m 4872 S 2.0 0.1 2:05.27 php-cgi
7044 www 15 0 24348 19m 932 S 0.7 0.2 1:58.38 nginx

Only part of the content changes constantly.

I can only output a single line keeps changing constantly without newline:

import  sys
import  time

if __name__ == '__main__':
    i = 0
    while True:
        sys.stdout.write('i = %d.\r' % i)
        sys.stdout.flush()
        time.sleep(1)
        i += 1

I want to know how to output multiline like the top command(keeps changing constantly without newline).

Sorry, My English is poor. Hope that makes sense.

Thanks,
Qi

  • 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-27T15:17:24+00:00Added an answer on May 27, 2026 at 3:17 pm

    You will need to use a library for handling the interaction with the console, e.g. http://docs.python.org/howto/curses.html

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

Sidebar

Related Questions

I want to output top 10 lines of AWK command in the list of
The output of /proc/net/dev on Linux looks like this: Inter-| Receive | Transmit face
I'm running a Linux 2.6.36 kernel, and I'm seeing some random errors. Things like
I've got to save the output of the top command into a variable and
reflog vs GITK http://siteroller.net/archive/images/Forums/headless%20GIT.png The top image is the output of: git reflog. The
The output of this echo is not passed on to the next command using
I want to convert CSS to SCSS that looks like this: .top { margin-top:
I am running a find command for a particular file that I know exists.
I'm working on a Markdown command line program, and I'd like to format source
Is it possible to show interactive shell command output on a webpage without refreshing

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.