LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training 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 12-06-2007, 12:39 PM   #1
linuxxx123
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Rep: Reputation: 0
Hw to clear the selected lines from History?


From the help of this forem I have got hw to clear the history..using history -c .. But how to clear the particular lines from the history, insted of deleting whole history lines.. I am expecting the positive replies from seniors...
 
Old 12-06-2007, 12:57 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Hi linuxxx123!

I hope you are talking about bash. I really don't know what you mean by "hw". It that is the case, this might help you:

http://www.ss64.com/bash/history.html

You can also delete lines manually, I suppose, by editing you ~/.bash_history. It is a simple text file that you can edit with any text-editor. I never did it though...
 
Old 12-06-2007, 01:54 PM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,402
Blog Entries: 1

Rep: Reputation: 64
There is a small trick I learned just a few weeks ago that can help you: any commands preceded by one or more spaces are not recorded in history as in " ls /etc".

And you set a list of commands in shell variable HISTIGNORE. The commands in this list are not recorded in the history. For example, mine looks like:
Code:
HISTIGNORE=encfs:amule:fusermount:mplayer
 
Old 12-10-2007, 02:59 PM   #4
linuxxx123
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks a lot

Thank you for all valuable replies... History -d command is exactly fulfill my requirement.. But I canít able to use this command for delete more than one line. Please explain me how to use this command for delete the more number of selected lines. For example delete the line 25 to 56 from bash.

Once again thank you for your valuable replies.
 
Old 12-11-2007, 01:05 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
Just add a loop around the cmd, specifying which line nums to delete.
 
Old 12-11-2007, 02:50 AM   #6
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
How about just more or less manually altering the history file (like .bash_history), maybe with sed or something?
 
Old 01-08-2009, 03:56 PM   #7
deepsix
Member
 
Registered: Apr 2003
Distribution: ANY
Posts: 339

Rep: Reputation: 32
If you just want the history erased try this.

"rm .bash_history" ...next time you login and issue a command bash will create a new history file with a clean slate.
 
  


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
How do I clear history in Linux ibrahimt Linux - Security 8 07-14-2009 02:15 AM
How to clear history hi_msh Linux - Newbie 2 01-12-2006 05:40 AM
history clear command suguname Linux - Newbie 5 03-05-2005 09:32 AM
How do I clear all my RedHat 9 History? PionexUser Linux - General 1 11-20-2003 10:42 AM
Clear History Mystified Linux - Newbie 1 03-25-2002 09:27 AM

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

All times are GMT -5. The time now is 11:50 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