LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-28-2010, 07:42 AM   #1
ayongying
Member
 
Registered: Mar 2010
Location: Bei Jing
Posts: 41

Rep: Reputation: 15
How to Look at history file in unix shell for a user


How to Look at history file in unix shell for a user, find 5 most often used commands.
Thanks
 
Old 05-28-2010, 07:47 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

Code:
history | tail -5
for the logged in user. Otherwise as root
Code:
tail -5 /home/username/.sh_history
(AIX Unix)

Kind regards,

Eric

Last edited by EricTRA; 05-28-2010 at 07:49 AM.
 
1 members found this post helpful.
Old 05-28-2010, 07:59 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

You seem to be presenting requests for simple information. I suggest that you can get some background from;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Bash Reference Manual
Advanced Bash-Scripting Guide
Linux Home Networking
Virtualiation- Top 10


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
1 members found this post helpful.
Old 05-28-2010, 10:43 PM   #4
ayongying
Member
 
Registered: Mar 2010
Location: Bei Jing
Posts: 41

Original Poster
Rep: Reputation: 15
another answer,I am not sure whether it is right

code:
history | awk '{a[$1]++}END{for(i in a){print i,a[i] }}'
 
Old 05-28-2010, 11:34 PM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

If you're not sure, then why not test it? You'll know at an instance if it works or not.

Kind regards,

Eric
 
Old 05-29-2010, 02:37 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Lightbulb

Quote:
Originally Posted by ayongying View Post
find 5 most often used commands.
Thanks
This gives you the 10 most used commands.

Code:
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unix shell script:How to delete the first line in a file?? rche3252 Programming 6 03-03-2010 07:32 AM
Unix shell with history features like in bash vipin_jss Linux - Newbie 1 05-23-2009 10:48 PM
history -c in shell file does not work babu198649 Linux - Newbie 5 05-09-2009 08:32 AM
Implement a Unix Shell with History Feature vipin_jss Linux - Newbie 2 05-07-2009 07:38 PM
tcsh: can you save the history from multiple shells to one history file? BrianK General 2 04-23-2009 05:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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