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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:18:08+00:00 2026-05-11T09:18:08+00:00

In most modern shells, you can hit the up and down arrows and it

  • 0

In most modern shells, you can hit the up and down arrows and it will put, at the prompt, previous commands that you have executed. My question is, how does this work?!

It seems to me that the shell is somehow manipulating stdout to overwrite what it has already written?

I notice that programs like wget do this as well. Does anybody have any idea how they do it?

  • 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-11T09:18:09+00:00Added an answer on May 11, 2026 at 9:18 am

    It’s not manipulating stdout — it’s overwriting the characters which have already been displayed by the terminal.

    Try this:

    #include <stdio.h> #include <unistd.h> static char bar[] = '======================================='                     '======================================>'; int main() {     int i;     for (i = 77; i >= 0; i--) {         printf('[%s]\r', &bar[i]);         fflush(stdout);         sleep(1);     }     printf('\n');     return 0; } 

    That’s pretty close to wget‘s output, right? \r is a carriage-return, which the terminal interprets as ‘move the cursor back to the start of the current line’.

    Your shell, if it’s bash, uses the GNU Readline library, which provides much more general functionality, including detecting terminal types, history management, programmable key bindings, etc.

    One more thing — when in doubt, the source for your wget, your shell, etc. are all available.

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

Sidebar

Related Questions

In most modern IDEs there is a parameter that you can set to ensure
In most modern systems, the system will automatically create extra files that are unnecessary.
Where can I find the most modern tutorial that teaches tkinter together with ttk
Now that most modern browsers support AJAX and client-side requests without performing a POST,
It appears that most modern languages and tools allow for extended regular expressions, and
Okay, so we all know that most modern browsers (without tweaking) are set to
I'm aware that most things in modern programming languages are at least partially based
I have a list of strings that are all early modern English words ending
It seems like most modern(as in, past 20 years) processors have used little endian,
Saving and auto-filing of username/password is a feature of most modern browsers. And the

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.