How to cut/sort a specific part of the log file

Post Reply
a24uall
Site Admin
Posts: 166
Joined: Sun Jul 01, 2012 9:07 am

How to cut/sort a specific part of the log file

Post by a24uall »

tail -100 /var/log/messages | awk {'print $3'}

Code: Select all

root@server [~]# tail -100 /var/log/messages | awk {'print $3'}
21:42:06
21:42:06
21:42:10
21:42:10
Arun
WebhostingDevelopment.com
a24uall
Site Admin
Posts: 166
Joined: Sun Jul 01, 2012 9:07 am

Re: How to cut/sort a specific part of the log file

Post by a24uall »

How to SORT the result we have cut just now.
tail -100 /var/log/messages | awk {'print $5'} | sort
root@server [~]# tail -100 /var/log/messages | awk {'print $5'} | sort
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
named[22529]:
named[22529]:
named[22529]:
named[22529]:
named[22529]:
named[22529]:
named[22529]:
named[22529]:
Arun
WebhostingDevelopment.com
Post Reply

Return to “Basic (Small scripts)”