Register
It is currently Sat Oct 25, 2014 11:08 pm

command history script help


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Fri Jun 05, 2009 5:21 am   

Joined: Fri Jun 05, 2009 5:17 am
Posts: 1
hey i need a script for linux in bash that shows me the command line history of a user with the possibility of choosing the period.

if anyone can help me i'd really appreciate it.

thank you very much.


Top
 Profile  
 PostPosted: Tue Jun 09, 2009 6:03 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
a users history is just stored in a text file in the users home dir;

~user/.bash_history

there is no way to identify when any command was run unless you alter the way history is stored


Top
 Profile  
 PostPosted: Tue Jun 09, 2009 6:28 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
This is somewhat untested (since i don't have a bash shell near me).

But apperantly this should work fine.
HISTTIMEFORMAT="%D %T "

Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Wed Jul 22, 2009 1:27 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Fredrik, I LOVE that!

Here's the normal output of the "history" command:

Code:
linux-ti33:~> history|head -n1
    1  ping yahoo.com


Then I set the HISTTIMEFORMAT variable:

Code:
linux-ti33:~> HISTTIMEFORMAT="%D %T "
linux-ti33:~> history|head -n1
    1  07/22/09 12:22:33 ping yahoo.com


Did that do what you needed TeaM17cr?


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP