LinuxQuestions.org
Visit Jeremy's Blog.
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 06-07-2015, 08:24 AM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 490

Rep: Reputation: 30
Append bash history to another file during logout


Hi friends ,

I am using Redhat Linux 5.6 . I want to delete all my 'history' command information during logout , but before deleting it copies to a new file .
Also , each time of logout , it appends the new history command of that particular new file .

Is anybody help me to do this ?
 
Old 06-07-2015, 10:05 AM   #2
jmgibson1981
Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Ubuntu LTS
Posts: 125

Rep: Reputation: Disabled
Code:
man history
In the case of current Ubuntu Server the command you would want would be something like this. I'd imagine RedHat would be similar but the man command will tell you what you want specifically.

Code:
cat ~/.bash_history >> yourfile
rm ~/.bash_history
 
Old 06-08-2015, 02:00 AM   #3
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 490

Original Poster
Rep: Reputation: 30
Thx jmgibson ,

But I want to append the output during logout time .
Also I want to add date i.e., ' HISTTIMEFORMAT' with the .bash_history output .
 
Old 06-08-2015, 03:09 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,500

Rep: Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431
there is a ~/.bash_logout file, see man bash about its usage. Probably that's what you need.
 
Old 06-08-2015, 03:31 AM   #5
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 490

Original Poster
Rep: Reputation: 30
Thx all for help me .
 
  


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
append to end of each file -- -bash: *: ambiguous redirect allele Linux - Software 7 06-03-2009 02:57 PM
bash - find and append to each file found djgerbavore Linux - General 5 11-12-2008 11:14 AM
how to clear bash history at logout yhus Linux - Software 6 09-27-2007 07:08 PM
BASH append to middle of file baks Programming 4 02-28-2007 04:27 AM
how do i erase my history file on logout yawe_frek Linux - General 7 11-25-2006 01:45 AM


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