Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Rather than scroll past hundreds of lines of output to see the previous command history, can the output of the last command be cleared? E.g. after executing ls, clear its output because you don't need it any more.


This is not your usual clear or ctrl+L operation. The idea is to scroll back though the history looking for the output of a previous command, but without having to have to scroll past a load of ls, or cat, or sudo apt-get install output unless I really want to. It might look something like this:

cat fileIWantToRemember
ls directoryIWantToForget
# some command that wipes the output of ls
# scroll back to see the output of cat immediately
share|improve this question
Do you mean to clear the output, or to remove the command from your command history? If you want to modify your command history, maybe this thread addresses what you're looking for? – ernie Sep 24 '13 at 23:40
The terminal just displays a stream of text, and stores some in its own internal buffer. It has no way of knowing, or discriminating between command output. The rxvt-unicode terminal does have a perl interpreter that might be able to implement something like this. But as far as I know it's not done. – Keith Sep 25 '13 at 4:06
A long time ago, I used a terminal emulator on Mac OS X which had this feature, but I can't remember what it was called any more. It wasn't free, though. However, while doing a quick google search for it, I ran into, which looks like it is trying to implement that feature. However, "Final Term is in heavy development and neither stable nor feature complete!", so I didn't try it. Looks interesting, though. The google search, for what it's worth, was terminal emulator output folding – rici Sep 25 '13 at 4:38
Final Term is heavily-enough developed to fold commands (and lots of other amazing stuff), and once there's a keyboard shortcut to do that then problem solved. I was beginning to think I was crazy... – nacnudus Sep 25 '13 at 10:50
@nacnudus: If you try it and it works for you, you should self-answer the question. That will provide guidance for other people with the same problem. – rici Sep 25 '13 at 15:28

I think you are looking for the clear command...


"clear" clears your last command from view. You can scroll up in the terminal to see it again if need be.

share|improve this answer
The point is to not have to scroll past it when looking through your history for something else. – nacnudus Sep 24 '13 at 23:34
Do you mean you want to suppress the output from the command? If yes, this may help you:… – phe0113 Sep 24 '13 at 23:41
That's great if I never want to see output. I want to see the output the first time, and then forget about it. So in the example I gave, I want to inspect the output of ls for some reason, but then I want to get rid of it so that I don't have to keep scrolling past it to find the output of cat. Obviously I could just do cat again, but I can imagine wanting to retain a sequence of commands, and it would be nice not to have to repeat them all. – nacnudus Sep 25 '13 at 0:00

In bash, you can press the shortcut Ctrl + L to clear the screen, similar to the clear command. (

Or, you can use history | tail -3 to see the last three commands. (

share|improve this answer
See my comment to @Justin below, the point is not to have to scroll past it when looking through the history for something else. Something like HISTCONTROL=ignorespace in your second link that you can use after the fact would be good. – nacnudus Sep 24 '13 at 23:42
I'm a bit lost on what you want to achieve. Another thought, in many consoles I used, you can usually use arrow keys to browse command history in bash, does this apply to your situation? – phe0113 Sep 24 '13 at 23:47
Does my edit clarify the question? – nacnudus Sep 24 '13 at 23:56
@nacnudus, yes, I get your point now :) – phe0113 Sep 25 '13 at 0:22

It sounds as if you want to remove items from your history. To do this, you'll first need to enable the writing of history on the fly, rather than on logout by editing your ~/.bashrc and adding:

shopt -s histappend; export PROMPT_COMMAND='history -a';'

Then, to delete items you can do:

history -d offset, where offset is the history entry you want to delete

Based on this forum thread.

share|improve this answer
This seems to delete it from the history file, which is almost the right idea, but can it wipe it from the current terminal? – nacnudus Sep 24 '13 at 23:56
up vote 0 down vote accepted

With thanks to @rici, this behaviour can be called "folding". The output of commands isn't forgotten, but you can hide it until you need it again. Folding is common in text editors but seems to be rare in terminal emulators.

Final Term is a new terminal emulator that includes folding among many other fancy tricks. Beware: "Final Term is in heavy development and neither stable nor feature complete!" It was heavily-enough developed to fold my commands when I tested it, but too unstable not to crash. One to watch.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .