LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   clear command history in tcsh (http://www.linuxquestions.org/questions/linux-newbie-8/clear-command-history-in-tcsh-776584/)

curos 12-17-2009 11:15 PM

clear command history in tcsh
 
How do you clear your command history? I don't mean the history you get when you run
Code:

history
and that you can delete with
Code:

history -c
I mean the history you get when you press up on your keyboard and it shows you the last few commands that you have run (and allows you to reexecute them if you want to).

I noticed a file in my home directory ~/.history
It contained the history of my commands. I tried deleting the file, but when I logout and log back in, the .history file is recreated with all the history still there. I guess it must store it in memory. So how do you go about clearing the command history?

btw, I'm using tcsh

sumeet inani 12-17-2009 11:20 PM

I have bash.I do as follows BUT there is tip for you at end to locate corresponding file.
Code:

Edit your file ~/.bashrc
There must be a line
shopt -s histappend
comment it by prefixing with #
now open a terminal & run history -c.
Your history will be permanently erased
& even if you press up key just hear a beep.

search in your home for file that contains word histappend to replace ~/.bashrc.
Try
Code:

find ~ -type f -exec grep -l -i  histappend '{}' ';'
I can explain command if you are interested to know.
if you find this post useful than thank me by pressing thumbs up button.Thank You.

curos 12-17-2009 11:44 PM

Sorry, but I'm not running bash, so shopt is not an available command and would not affect tcsh.

I actually found out how to do it from reading http://forums11.itrc.hp.com/service/...hreadId=957353

basically, i did:

Code:

set history=0
logged out and then logged back in. Good as new!

sumeet inani 12-18-2009 12:17 AM

can you show output of this command
Code:

find ~ -type f -exec grep -l -i  histappend '{}' ';'
just i would like to know if there is a similiarity between config of bash & tcsh.

curos 12-18-2009 12:26 AM

hi sumeet. I ran the command, but there was no output.

EDIT:
and i understand what the command does; do a grep on all files for the substring histappend and print the file if it contains that string. ignore case.

sumeet inani 12-18-2009 03:38 AM

Another things to note in my code was
-l --stop search in file when you find first match & also instead of mentioning the whole line just give file name.
Actually first I had tried
grep -ir 'histappend' *
but I think in this case files with . at beginning are excluded so I had to go for -exec option in 'find' command.
Looks like you also know a lot about commands.
Pleased to meet you.


All times are GMT -5. The time now is 02:55 AM.