LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2008, 09:47 AM   #1
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 307

Rep: Reputation: 41
Prompt History


Does anyone no how I can clear the history of my command prompt. I usually use the repeat function when programming, but now I have a bunch of other commands in between so it's not as convenient.

Just so I'm not confusing. When at the command prompt, I can push the up arrow to scroll through past entered commands. But there is a history of weeks of mistype and deleted files, can I clear that history?

Thanks in advance.
Ace
 
Old 11-13-2008, 09:51 AM   #2
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 307

Original Poster
Rep: Reputation: 41
Eureka..I think

I think I found it.

history -c

Right?

Thanks anyways.
Ace
 
Old 11-13-2008, 09:52 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you can just delete the ~/.bash_history file for a one of shot over logout. you can also set the HISTSIZE option to a lower value in your .bashrc to reduce the number of saved commands, or add "unset HISTFILE" to not save it to disk at all.
 
Old 11-13-2008, 10:04 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
Here are two more shell variable options for you to help keep your history sane.

Use "HISTCONTROL=ignoredups" to keep the history from recording multiple instances of the same command, or use "erasedups" instead to keep only the most recent entry.

And using "HISTIGNORE=colon:separated:list:of:commands" will make it ignore any commands that you don't want to see at all.

There are more options you can use. Check out the bash man page.

Edit: here's one more that I use often--history searching. Hitting crtl+r, then typing something will bring up the most recent matching string in your history. Hit it again for the next match, or crtl+s to move forward again. Makes it easy to jump back to previously-used commands.

Last edited by David the H.; 11-13-2008 at 10:12 AM.
 
Old 11-13-2008, 10:09 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
I never knew that, interesting.
 
Old 11-13-2008, 10:51 AM   #6
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 307

Original Poster
Rep: Reputation: 41
Thanks

Thanks for taking the time and the resulting info guys.

Ace
 
Old 11-13-2008, 12:22 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by David the H. View Post
Here are two more shell variable options for you to help keep your history sane.

Use "HISTCONTROL=ignoredups" to keep the history from recording multiple instances of the same command, or use "erasedups" instead to keep only the most recent entry.

And using "HISTIGNORE=colon:separated:list:of:commands" will make it ignore any commands that you don't want to see at all.

There are more options you can use. Check out the bash man page.

Edit: here's one more that I use often--history searching. Hitting crtl+r, then typing something will bring up the most recent matching string in your history. Hit it again for the next match, or crtl+s to move forward again. Makes it easy to jump back to previously-used commands.

Another "goodie" in this context is how to handle
the ~/.bash_history if you have several terminals
open and use them all intermittently (wanting to
retain the history in one big file):
Code:
# handle history file gracefully for multiple windows open
shopt -s histappend
export PROMPT_COMMAND='history -a'

Cheers,
Tink
 
Old 11-13-2008, 12:53 PM   #8
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware -current, 14.1
Posts: 1,076

Rep: Reputation: 189Reputation: 189
I, too, would like to thank the contributors....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
history junaid18183 Linux - General 14 11-07-2009 08:01 AM
Editing command prompt history travisvermaak Linux - Newbie 9 04-20-2006 11:52 AM
Download history and copy history? inverted.gravity Linux - Newbie 1 02-21-2006 01:31 PM
How to find back "history" database after "history -c" ? san_lss Linux - Newbie 1 01-07-2004 12:53 PM
History neohybrid1 Linux - General 1 12-03-2002 05:53 AM


All times are GMT -5. The time now is 10:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration