History


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting History
# 1  
Old 05-19-2008
History

Hi I am new here.Hope this has not been already posted.I searched,but couldn't find.
I am currently learning and using lots of new bash commands,I even check sites and try out commands,or visit folders like /usr/bin and /bin etc and just man many of them and try them.
The thing is..I forget some of such commands.I want to save my entire commands history whenever I quit.
Currently the HISTFILESIZE is 500 and that is not enough at all.
I want to write a script to save my history (from all terminal sessions) to some file in appending manner.
Also how do I permanently increase my history file size.
export $HISTFILESIZE=10000 made it so temporarily only..the file still stores only 500.
# 2  
Old 05-19-2008
maybe you should try to use script command instead.

do man script
# 3  
Old 05-19-2008
Quote:
Originally Posted by Vivek788
Currently the HISTFILESIZE is 500 and that is not enough at all.
I want to write a script to save my history (from all terminal sessions) to some file in appending manner.

Hi,

you pls open vi /etc/profile and search "HISTSIZE" and you will change value and logout from terminal and again login and print $echo $HISTSIZE you will must see change.

Cheers,
Bash
# 4  
Old 05-19-2008
When I started my current job, I had to learn a lot of things that were new to me on the command line. I found that the best way to remember the syntax of our internal applications was to search my history file.

So, I threw a little line into my .bash_logout so that I would keep a perpetual history of all my commands. It's a bit more useful than the history, because there is no limit and it eliminates duplicates.

Code:
history | perl -pe 's/^\s+\d+\s+//' | sort | uniq >> ~/.old_commands.log && cat ~/.old_commands.log | sort | uniq > ~/old_commands.log && cp ~/old_commands.log ~/.old_commands.log

What it does: Take the history, strip off leading digits (the command sequence number), and add them to a file, sorted and unique. I'm sure people on here will find some ways to improve it, but it works well enough for me as-is, and has helped me a great many times.

ShawnMilo
# 5  
Old 05-20-2008
Quote:
Originally Posted by ShawnMilo
When I started my current job, I had to learn a lot of things that were new to me on the command line. I found that the best way to remember the syntax of our internal applications was to search my history file.

So, I threw a little line into my .bash_logout so that I would keep a perpetual history of all my commands. It's a bit more useful than the history, because there is no limit and it eliminates duplicates.

Code:
history | perl -pe 's/^\s+\d+\s+//' | sort | uniq >> ~/.old_commands.log && cat ~/.old_commands.log | sort | uniq > ~/old_commands.log && cp ~/old_commands.log ~/.old_commands.log

What it does: Take the history, strip off leading digits (the command sequence number), and add them to a file, sorted and unique. I'm sure people on here will find some ways to improve it, but it works well enough for me as-is, and has helped me a great many times.

ShawnMilo

Hm.. I too just put it into my bash_logout.Let see how it goes.I also found another interesting link my friend provided.

Code:
http://london.pm.org/pipermail/london.pm/Week-of-Mon-20070611/008584.html

# 6  
Old 05-21-2008
but hey let me ask..bash_logout doesn't execute when I close my terminal sessions does it?
The file old_commands.log has not yet been created.
# 7  
Old 05-21-2008
Quote:
Originally Posted by Vivek788
but hey let me ask..bash_logout doesn't execute when I close my terminal sessions does it?
The file old_commands.log has not yet been created.
It executes for me on logout. Are you sure you're using bash? Also, the filename should begin with a period: .bash_logout

It's not clear from your message how you have named it.

Shawn
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

The Great History of UNIX (1969-1999) | 30 Years of UNIX History | YouTube Video

I am pleased to announce this new video in 1080 HD for UNIX lovers honoring thirty years of UNIX history spanning from 1969 to 1999 presented in 150 seconds (two and a half minutes) in 1080 HD, celebrating the 50th anniversary of UNIX. The Great History of UNIX (1969-1999) | 30 Years of UNIX... (8 Replies)
Discussion started by: Neo
8 Replies

2. UNIX for Dummies Questions & Answers

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (1 Reply)
Discussion started by: sriky86
1 Replies

3. AIX

history

Hi How to see all the commands typed as user padmin in the vio servers ? history command shows only a few commands ? (1 Reply)
Discussion started by: newtoaixos
1 Replies

4. UNIX for Dummies Questions & Answers

The history command: See other users command history

Can anyone tell this: If two users are logged into the same server from different locations. Is there a way to see the history command of the other user? I tried the history command, but it is showing me only the commands I used. Thanks in advance for your help. Iamnew2solaris (1 Reply)
Discussion started by: iamnew2solaris
1 Replies

5. UNIX for Advanced & Expert Users

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (3 Replies)
Discussion started by: linuxadmin
3 Replies

6. UNIX for Dummies Questions & Answers

How to review the history and the commands that has been done in this history?

Hello every body, Kindly inform me How Do i find out the time I executed a command previously on UNIX Solaris?? To be more specific and more clear about what i want to know is that I want a command the enables me to know the history and which command i run at this history/time. FYI I used... (5 Replies)
Discussion started by: ahmedamer12
5 Replies

7. Shell Programming and Scripting

History ??

Hi, How can i see first 3 commands that are there in history {fc -l} ? Thanks (1 Reply)
Discussion started by: varungupta
1 Replies

8. UNIX for Dummies Questions & Answers

History

hi there all , i would like to know what are the other alternatives besides .sh_history file to get all commands typed on console .. Can u help me ? Thanks for all PS : I'm a newbie on this forum :rolleyes: (2 Replies)
Discussion started by: JuniorJack
2 Replies
Login or Register to Ask a Question