Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-12-2010, 01:50 PM   #1
Registered: Oct 2009
Distribution: Arch Linux
Posts: 89

Rep: Reputation: 18
How to delete bash terminal history upto certain no. of commands

i want to delete some say 10 previous commands in bash shell!! what shud i do??
Old 01-12-2010, 01:55 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,986
Blog Entries: 14

Rep: Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187Reputation: 1187
Why would you be wanting to cover your tracks like that?
Old 01-12-2010, 01:57 PM   #3
LQ Newbie
Registered: Mar 2005
Location: Ohio
Distribution: Several (Gentoo, Red Hat/Fedora, HP-UX, Helix)
Posts: 26

Rep: Reputation: 17
Try editing ~/.bash_history. If that doesn't work, IDK. I think there is a way to get bash to not add it to history at all, but I don't recall exactly how it's done. I stumbled upon it once by accident...
Old 01-12-2010, 02:13 PM   #4
Senior Member
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,093

Rep: Reputation: 197Reputation: 197
Originally Posted by sd|| View Post
i want to delete some say 10 previous commands in bash shell!! what shud i do??

Bash history is usually stored in ~/.bash_history but it's location can be controlled by setting $HISTFILE
The history file is only written when the shell exits, so you can delete the last ten lines from a history file but that might not be what you want.
You can prevent anything from being written to the history file by setting the value of $HISTSIZE to 0. Or I guess you could set $HISTFILE to /dev/null.

See also


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
Bash history delete command from bash itself ashishag Linux - Software 6 05-02-2010 03:39 AM
Can't delete old history in gstreamer lrusso Linux - Newbie 1 08-17-2009 01:30 PM
Delete history does not work patsyking Linux - Newbie 30 01-04-2009 06:57 PM
Missing commands in Bash/Terminal cferris Red Hat 3 10-12-2003 11:13 PM
delete konqueror history ? qwijibow Linux - Newbie 1 08-22-2003 03:18 PM > Forums > Linux Forums > Linux - Newbie

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

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