Extremely rusty on my scripting and need help!

Hello everyone, hope that your holiday's were good. I am getting back into some System Admin work after taking last year off and feeling a little rust.

I am doing some reporting and I have a log file that I need to pull some information from. And here is what the extract is from the log file. It has a bunch of data that I don't need but does contain the stuff I need.

*--*--*--*--*--*--*--*--*
( interface data )
*--*--*--*--*--*--*--*--*

interface speed pkts pkts pkts pkts bits bits errors trunk
Mb/s in out drop coll in out
admn DN 100 FD 0 1 0 0 0 560 0
I.1 UP 1000 FD 3.578G 4.068G 88917 0 9.919T 21.37T 0
I.2 UP 1000 FD 4.620G 4.063G 88506 0 21.91T 10.30T 0

I need to pull the lines (roughly 10) that are following from the interface data line. I am having a problem doing that and was seeing if you guys had something quick and easy.

Thanks in Advance.

Use sed or awk to extract the line you want.

If you want more detail, you'll have to be more specific.

What do you need?
What don't you need?

Sorry I had a lot of detail in the first post that got wiped somehow. I am in need of the line entries from the log file that follow the Interface Data Line so that i could report on dropped packets. So I need the complete lines for the interfaces so that I can review and see if there is any dropped packets. I ended up finding some old sed commands from some of my older scripts and it will work for the extraction but see if there is something cleaner to keep for the formating of the lines from the orginal data file into the new file. Cause it currently pulls it but outputs it into a single string.

Here is what I have found and am trying to use.

DRPPKT=`sed -n '/( interface data )/,/( interface trunks )/p' filename`
echo ${DRPPKT}

An example how to print the line with the pattern and 3 lines after the pattern:

awk '/pattern/{p=1}p && c++<=3' file

Thx Guys I got it. I used a combination of awk and sed in my report generator that worked for me. I hate being rusty and not using a skill for a long time and then relearning it again. Thx for your guys' help!

Glad you got it working. Another method would be:

grep -A 10 "interface data" your_log

This assumes the proper version of grep though.

Yeah this is on Solaris 10 box and the orginal grep doesn't support the -A function as that was my first solution. Then I went to sunfreeware to grab their version hoping it supported it but no avail. In the past I have pulled the file from a linux box but I didn't have one available. LOL

But thanks for the support.