LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-26-2010, 10:27 AM   #1
sd||
Member
 
Registered: Oct 2009
Distribution: Arch Linux
Posts: 89

Rep: Reputation: 18
history -c is not working in bash script


i wrote a script to run over a macintosh system

Quote:
#!/bin/bash
history -c
clear
but the script not doing what i am trying to achieve.

what could be the explanation for that.

Last edited by sd||; 03-26-2010 at 01:52 PM.
 
Old 03-26-2010, 12:02 PM   #2
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
It might help if you actually explained what you're trying to achieve.

For one thing, the clear history command only clears the memory of the running shell session. When a terminal exits, any history in ram gets written to your history file; and this file is then re-loaded when a new terminal is started. If you want to prevent that saved history from being loaded you have to clear or delete the history file instead, or start the session with the history function turned off.

(Edit: or add the "history -c" to your bashrc so that it gets run when the terminal is launched.)

See the HISTORY section of the bash man page for more.

Last edited by David the H.; 03-26-2010 at 12:11 PM.
 
  


Reply



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
Help! Bash script not working cynthiatan General 2 11-10-2008 01:45 AM
Linux Bash Script Not Working?? helptonewbie Programming 12 08-15-2006 12:57 PM
history not working in bash subu_s AIX 2 12-29-2004 12:49 PM
bash script not working :'( aesahaettr Linux - Software 5 05-12-2004 01:08 AM
Bash script not working AMMullan Linux - General 2 09-28-2003 07:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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