counting the number of lines

Hello,

I have afile which begins with a few urls on multiple lines and then there is listing of some information on separate lines.

The listing begins with the word Name on a given line followed by teh actual list.

I want to count the number of lines in this file after the line having this "Name ' word.

wc -l gives me the total number of lines while i want onlly the number of lines after the line having "Name " in it.

I would appreciate a response.

Nayeem

Without knowing the file first hand, I can only suggest you use grep with options.

$ grep -c "Name" myfile

Will give the number of lines that the word "Name" is found.

Re-read your post - my grep suggestion won't help.

Try awk - see the man page for awk
You can look for a begining statement and ending statement - and then pipe it to wc -l

Example (you will have to try this to see if it or something like it will work)
awk /"Name"/,/"Ending statement"/ myfile |wc -l

Google the command you suggested will give me the number of lines having the word Name in it.

I want the number of lines in the file follwing the line having name in it.
Name occurs only in one line.

So I want to count the number of lines in this file after this line having Name in it

Thanks

Nayeem

I tried using awk the way you suggested but this also gives me only one line which is the one having the word Name in it.
I wanted to know the number of lines after this line

You have to change the ending statement to something that is in the file -

Example:
cat myfile
First line
Name line
another line
even more lines
ending line

$ cat myfile |awk /"Name"/,/"even"/ |wc -l
3
So it's going to count the Name line, another line, and the last line - set the output of wc to a variable and minus 1 - but you need to put an ending statement in the awk parameters that is in your file or put something that won't ever be there (in this next example "neverfindthisword" ) and it will count all lines after (including) the Name line

$ cat myfile |awk /"Name"/,/"neverfindthisword"/ |wc -l
4

You might want to post the OS and version - there may be differences in the awk program you use.

Yes, sorry. I posted that then quickly deleted that after I realized it was flat out wrong. You probably should use sed. Use Name as the first address and the end of the file as the second (Not sure how to do that - maybe others here know). Then count the lines in between.

How about:
sed '1,/Name/d' datafile | wc -l