LinuxQuestions.org
Review your favorite Linux distribution.
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, 08:47 AM   #1
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 345

Rep: Reputation: 54
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, 08:51 AM   #2
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 345

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

I think I found it.

history -c

Right?

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

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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, 09:04 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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 09:12 AM.
 
Old 11-13-2008, 09:09 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

Original Poster
Rep: Reputation: 54
Thanks

Thanks for taking the time and the resulting info guys.

Ace
 
Old 11-13-2008, 11:22 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 11:53 AM   #8
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware
Posts: 1,134

Rep: Reputation: 277Reputation: 277Reputation: 277
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 07:01 AM
Editing command prompt history travisvermaak Linux - Newbie 9 04-20-2006 10:52 AM
Download history and copy history? inverted.gravity Linux - Newbie 1 02-21-2006 12:31 PM
How to find back "history" database after "history -c" ? san_lss Linux - Newbie 1 01-07-2004 11:53 AM
History neohybrid1 Linux - General 1 12-03-2002 04:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:50 PM.

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
Open Source Consulting | Domain Registration