Visit The New, Modern Unix Linux Community

Top Forums Shell Programming and Scripting How to use command tail -f & show line number. Post 302575028 by ooilinlove on Sunday 20th of November 2011 12:18:28 AM
How to use command tail -f & show line number.

Hello Guys,
I have created function which is as follow:
Code:
tail -f filename |grep "Key word" 
output from this command 
Code:
19-11-2011 21:09:15,234 [49087][22830@YU:140649:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:15,286 [56166][22830@YU:53840:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:15,523 [146574][22830@YU:237562:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:16,022 [56166][22830@YU:237562:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:16,147 [56166][22830@YU:589:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:16,813 [56166][20030@ananke3:226720:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:17,823 [44002][20030@ananke3:53821:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:19,409 [49087][22830@YU:237562:null] - INFO Numbement - error number:result = :11
19-11-2011 21:09:22,367 [44002][20030@ananke3:53821:null] - INFO Numbement - error number:result = :11

I want output :
Code:
1    19-11-2011 21:09:15,234 [49087][22830@YU:140649:null] - INFO Numbement - error number:result = :11
2    19-11-2011 21:09:15,286 [56166][22830@YU:53840:null] - INFO Numbement - error number:result = :11
3    19-11-2011 21:09:15,523 [146574][22830@YU:237562:null] - INFO Numbement - error number:result = :11
4    19-11-2011 21:09:16,022 [56166][22830@YU:237562:null] - INFO Numbement - error number:result = :11
5    19-11-2011 21:09:16,147 [56166][22830@YU:589:null] - INFO Numbement - error number:result = :11
6    19-11-2011 21:09:16,813 [56166][20030@ananke3:226720:null] - INFO Numbement - error number:result = :11
7    19-11-2011 21:09:17,823 [44002][20030@ananke3:53821:null] - INFO Numbement - error number:result = :11
8    19-11-2011 21:09:19,409 [49087][22830@YU:237562:null] - INFO Numbement - error number:result = :11
9    19-11-2011 21:09:22,367 [44002][20030@ananke3:53821:null] - INFO Numbement - error number:result = :11


Smilie Please Help Me.Smilie
 
Test Your Knowledge in Computers #799
Difficulty: Medium
In digital numeral systems, the radix is the number of unique digits minus 1.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

tail command in SUN & HP_unix

Hi any SUN expert, All the while I using HP-Unix. Now when i turned into SUN environment, I not sure how the command should look like in SUN sys. HP: tail -n3 file.log (this is the command i normally use) SUN: tail (this 1 not work, donno where went wrong) Please help, thanks! (3 Replies)
Discussion started by: clemeot
3 Replies

2. UNIX for Dummies Questions & Answers

Making Emacs to show line number

Hi all How can I make Emacs to show the line numbers at the left or right as a default. This might help me to quickly jump to a given line. Thanks SS (9 Replies)
Discussion started by: saurya_s
9 Replies

3. UNIX for Dummies Questions & Answers

identifying duplicates line & reporting their line number

I need to find to find duplicate lines in a document and then print the line numbers of the duplicates The files contain multiple lines with about 100 numbers on each line I need something that will output the line numbers where duplicates were found ie 1=5=7, 2=34=76 Any suggestions would be... (5 Replies)
Discussion started by: stresslog
5 Replies

4. UNIX for Dummies Questions & Answers

how to display line number for tail -f

Hi, Just wonder if there is any quick way to display line number when monitoring a log file with tail -f? (4 Replies)
Discussion started by: iengca
4 Replies

5. Solaris

Tail command in one line

HI i have to copy the last 5000 lines form a log file and copy the same in the same file .overwriting the same log file. ex: tail -5000 testfile1 > testfile2 cat testfile2 mv tesftfile2 testfile1 will produce the correct result.but i want to have this done in one line???? (4 Replies)
Discussion started by: saurabh84g
4 Replies

6. Shell Programming and Scripting

tail command not show on screen

Hi, I'm moniroting duplicate text with unix command (tail -f trace75747 | grep 'duplicate'), but it showed many lines then it stop show trace information although trace information in this file trace75747 always got. What should I do? I look forward to hearing from you. THANKS! (10 Replies)
Discussion started by: seyha_moth
10 Replies

7. Shell Programming and Scripting

Show date/time with tail|grep command

Hi, I have a log file without date/time, and I want that everytime tail|grep find something it displays the date/time and the line. I have tried something like this command but without any luck to display the date/time: tail -F catalina.out | sed "s/^/`date `/" | egrep ... (6 Replies)
Discussion started by: julugu
6 Replies

8. Shell Programming and Scripting

Display Specific line number using tail command

Hi , 1)i want to display specific line number using tail command. e.g. display 10 line from end. Please help... 2)Want to display line 10 to 15 (from end)using tail command) (2 Replies)
Discussion started by: vivek1489
2 Replies

9. Homework & Coursework Questions

How to display certain line of file only using head or tail in 1 command?

First month learning about the Linux terminal and it has been a challenge yet fun so far. We're learning by using a gameshell. I'm trying to display a certain line ( only allowed 1 command ) from a file only using the head or tail. I'm pretty about this answer: head -23 history.txt | tail -1... (1 Reply)
Discussion started by: forzatekk
1 Replies

10. UNIX for Beginners Questions & Answers

Grep command to show the number of results

Hi I wanted to know if there is an option in grep command to show the number of results (not the number of lines of findings). Thanks (14 Replies)
Discussion started by: abdossamad2003
14 Replies
TAIL(1) 								FSF								   TAIL(1)

NAME
tail - output the last part of files SYNOPSIS
tail [OPTION]... [FILE]... DESCRIPTION
Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. --retry keep trying to open a file even if it is inaccessible when tail starts or if it becomes inaccessible later -- useful only with -f -c, --bytes=N output the last N bytes -f, --follow[={name|descriptor}] output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent -F same as --follow=name --retry -n, --lines=N output the last N lines, instead of the last 10 --max-unchanged-stats=N with --follow=name, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files) --pid=PID with -f, terminate after process ID, PID dies -q, --quiet, --silent never output headers giving file names -s, --sleep-interval=S with -f, sleep for approximately S seconds (default 1.0) between iterations. -v, --verbose always output headers giving file names --help display this help and exit --version output version information and exit If the first character of N (the number of bytes or lines) is a `+', print beginning with the Nth item from the start of each file, other- wise, print the last N items in the file. N may have a multiplier suffix: b for 512, k for 1024, m for 1048576 (1 Meg). With --follow (-f), tail defaults to following the file descriptor, which means that even if a tail'ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not the file descrip- tor (e.g., log rotation). Use --follow=name in that case. That causes tail to track the named file by reopening it periodically to see if it has been removed and recreated by some other program. AUTHOR
Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for tail is maintained as a Texinfo manual. If the info and tail programs are properly installed at your site, the command info tail should give you access to the complete manual. tail (coreutils) 4.5.3 February 2003 TAIL(1)

Featured Tech Videos

All times are GMT -4. The time now is 10:48 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy