DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.


Show the line number while monitoring the log files using tail -f command

You can combine the tail -f command using either cat or awk commands:

Method 1:

# tail -f syslog|cat -n

Method 2: 

# tail -f syslog|awk '{print NR,$0}'

You should get the similar output as below:

 1 Mar 4 15:21:07 oraserver local1:info Oracle Audit[1433636]: 
 2 Mar 4 15:21:07 oraserver local1:info Oracle Audit[4198698]:
 3 Mar 4 15:21:07 oraserver local1:info Oracle Audit[5456076]: 
 4 Mar 4 15:21:07 oraserver local1:info Oracle Audit[6545472]: 
 5 Mar 4 15:21:09 oraserver local1:info Oracle Audit[5456078]: 
 6 Mar 4 15:21:09 oraserver local1:info Oracle Audit[1609878]: 
 7 Mar 4 15:21:09 oraserver local1:info Oracle Audit[5456078]: 
 8 Mar 4 15:21:17 oraserver auth|security:info sshd[6545478]: 
 9 Mar 4 15:21:17 oraserver auth|security:info sshd[5456086]: 
 10 Mar 4 15:21:46 oraserver daemon:info CCIRMTD[295062]: