cat file1 read line-per-line then grep -A 15 lines down in fileb

STEP 1
# Set variable
FILE=/tmp/mainfile
SEARCHFILE =/tmp/searchfile

# THIS IS THE MAIN FILE.
cat /tmp/mainfile

Interface Ethernet0/0 "outside", is up, line protocol is up
Hardware is i82546GB rev03, BW 100 Mbps
Full-Duplex(Full-duplex), 100 Mbps(100 Mbps)
MAC address 001e.f75e.8cb4, MTU 1500
IP address 123.123.123.111, subnet mask 255.255.255.240
15297729 packets input, 8174892738 bytes, 0 no buffer
Received 236841 broadcasts, 0 runts, 0 giants
43908 input errors, 43908 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
0 L2 decode drops
15441190 packets output, 2300060743 bytes, 0 underruns
0 output errors, 0 collisions, 28 interface resets
0 late collisions, 0 deferred
0 input reset drops, 0 output reset drops
input queue (curr/max packets): hardware (1/32)
output queue (curr/max packets): hardware (0/25)
Traffic Statistics for "outside":
15297726 packets input, 7894645734 bytes
15441203 packets output, 2018486096 bytes
116781 packets dropped
1 minute input rate 1 pkts/sec, 115 bytes/sec
1 minute output rate 1 pkts/sec, 313 bytes/sec
1 minute drop rate, 0 pkts/sec
5 minute input rate 2 pkts/sec, 204 bytes/sec
5 minute output rate 2 pkts/sec, 420 bytes/sec
5 minute drop rate, 0 pkts/sec
Interface Ethernet0/1 "", is up, line protocol is up
Hardware is i82546GB rev03, BW 100 Mbps
Full-Duplex(Full-duplex), 100 Mbps(100 Mbps)
Available but not configured via nameif
MAC address 001e.f75e.8cb5, MTU not set
IP address unassigned
3133505 packets input, 904670592 bytes, 0 no buffer
Received 2513696 broadcasts, 0 runts, 0 giants
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
6349 L2 decode drops
1826527 packets output, 177409972 bytes, 0 underruns
0 output errors, 0 collisions, 6 interface resets
0 late collisions, 0 deferred
0 input reset drops, 0 output reset drops
input queue (curr/max packets): hardware (4/25)
output queue (curr/max packets): hardware (0/8)
Interface Ethernet0/3 "", is up, line protocol is up
Hardware is i82546GB rev03, BW 100 Mbps
Full-Duplex(Full-duplex), 100 Mbps(100 Mbps)
Available but not configured via nameif
MAC address 001e.f75e.8cb7, MTU not set
IP address unassigned
9211950 packets input, 1513770657 bytes, 0 no buffer
Received 243852 broadcasts, 0 runts, 0 giants
9800 input errors, 9800 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
7 L2 decode drops
8161723 packets output, 3897403307 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 late collisions, 0 deferred
0 input reset drops, 0 output reset drops
input queue (curr/max packets): hardware (8/26)
output queue (curr/max packets): hardware (0/16)
Interface Ethernet0/3.13 "dmzout", is up, line protocol is up
VLAN identifier 13
MAC address 001e.f75e.8cb7, MTU 1500
IP address 123.123.123.115, subnet mask 255.255.255.0
Traffic Statistics for "dmzout":
3795768 packets input, 537313232 bytes
3146266 packets output, 1149119436 bytes
355 packets dropped
1 minute input rate 0 pkts/sec, 106 bytes/sec
1 minute output rate 0 pkts/sec, 77 bytes/sec
1 minute drop rate, 0 pkts/sec
5 minute input rate 0 pkts/sec, 99 bytes/sec
5 minute output rate 0 pkts/sec, 93 bytes/sec
5 minute drop rate, 0 pkts/sec
Interface Ethernet0/3.15 "proddmz", is administratively down, line protocol is down
VLAN identifier 15
MAC address 001e.f75e.8cb7, MTU 1500
IP address 123.123.123.116, subnet mask 255.255.255.0
Traffic Statistics for "proddmz":
0 packets input, 0 bytes
16 packets output, 448 bytes
0 packets dropped
1 minute input rate 0 pkts/sec, 0 bytes/sec
1 minute output rate 0 pkts/sec, 0 bytes/sec
1 minute drop rate, 0 pkts/sec
5 minute input rate 0 pkts/sec, 0 bytes/sec
5 minute output rate 0 pkts/sec, 0 bytes/sec
5 minute drop rate, 0 pkts/sec

STEP 2
# THIS WILL OUTPUT THAT WILL BECOME MY SEARCH STRING FILE.
cat $FILE | grep "Ethernet.* "\"\" | awk '{print $2 " " $3}' > searchfile

OUTPUT of above command
Ethernet0/1 "",
Ethernet0/3 "",

STEP 3
Must be able to read $SEARCHFILE line-per-line then grep 15 lines down within $FILE

STEP 4
# This will then output a CSV list that will be used to create or update a database.
I can short out this step need help with STEP 3 mainly.

PACKBYTESIN=`grep -A 15 "Ethernet.* "\"\" | grep "packets input" | awk '{print $4}'`
INPUTERRORS=`grep -A 15 "Ethernet.* "\"\" | grep "input errors" | awk '{print $1","$4","$6","$8","$10","$12}'`
DECODE=`grep -A 15 "Ethernet.* "\"\" | grep "decode" | awk '{print $1}'`
PACKOUT=`grep -A 15 "Ethernet.* "\"\" | grep "packets output" | awk '{print $1","$4","$6}'`
OUTPUTERROR=`grep -A 15 "Ethernet.* "\"\" | grep "output errors" | awk '{print $1","$4","$6}'`
LATECOLLISIONS=`grep -A 15 "Ethernet.* "\"\" | grep "collisions" | awk '{print $1","$4}'`
RESETDROP=`grep -A 15 "Ethernet.* "\"\" | grep "reset drop" | awk '{print $1","$5}'`

echo -e "$PACKBYTESIN,$INPUTERRORS,$DECODE,$PACKOUT,$OUTPUTERROR,$LATECOLLISIONS,$RESETDROP"

Urgent help needed.
THANKS IN ADVANCE

So you want to find in $FILE each line from $SEARCHFILE, and then get the next 15 lines from $FILE?

cat $SEARCHFILE | 
while read search; do
   grep -A 15 -F -- "$search" $FILE
done

cat $FILE | grep -A 15 "Ethernet.* "\"\" > outputfile

cat outputfile

Interface Ethernet0/1 "", is up, line protocol is up
Hardware is i82546GB rev03, BW 100 Mbps
Full-Duplex(Full-duplex), 100 Mbps(100 Mbps)
Available but not configured via nameif
MAC address 001e.f75e.8cb5, MTU not set
IP address unassigned
3133505 packets input, 904670592 bytes, 0 no buffer
Received 2513696 broadcasts, 0 runts, 0 giants
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
6349 L2 decode drops
1826527 packets output, 177409972 bytes, 0 underruns
0 output errors, 0 collisions, 6 interface resets
0 late collisions, 0 deferred
0 input reset drops, 0 output reset drops
input queue (curr/max packets): hardware (4/25)
output queue (curr/max packets): hardware (0/8)
--
Interface Ethernet0/3 "", is up, line protocol is up
Hardware is i82546GB rev03, BW 100 Mbps
Full-Duplex(Full-duplex), 100 Mbps(100 Mbps)
Available but not configured via nameif
MAC address 001e.f75e.8cb7, MTU not set
IP address unassigned
9211950 packets input, 1513770657 bytes, 0 no buffer
Received 243852 broadcasts, 0 runts, 0 giants
9800 input errors, 9800 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
7 L2 decode drops
8161723 packets output, 3897403307 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 late collisions, 0 deferred
0 input reset drops, 0 output reset drops
input queue (curr/max packets): hardware (8/26)
output queue (curr/max packets): hardware (0/16)

PACKBYTESIN=`cat outputfile | grep -A 15 "Ethernet.* "\"\" | grep "packets input" | awk '{print $4}'`
INPUTERRORS=`cat outputfile | grep -A 15 "Ethernet.* "\"\" | grep "input errors" | awk '{print $1","$4","$6","$8","$10","$12}'`
DECODE=`cat outputfile | grep -A 15 "Ethernet.* "\"\" | grep "decode" | awk '{print $1}'`

echo -e "$PACKBYTESIN,$INPUTERRORS,$DECODE"

Now all my information gets mixed up.
Instead of getting information from line containing

Ethernet0/1

then

Ethernet0/3

THANKS IN ADVANCE

Useless use of cat, grep and awk.
Maybe you want to start from here:

awk '/Interface/{if(a)print a;a=$2}/input errors/{a=a FS $0}/decode/{a=a FS $0}END{print a}' fileoutput

I don't see a compelling reason to make the grep string more complicated than
just "Ethernet".... but.... here ya go:

grep Ethernet.*\"\" original_log_file |
cut -d' ' -f2 > a

for line in `cat a`; do

#----------------------------------------------------------------------#
# more finds the first instance of string... #
#----------------------------------------------------------------------#
more +/"$line" original_log_file |
head -15 |
egrep '(packets input|input errors|decode)' > b

#----------------------------------------------------------------------#
# Now all the information for a given Ethernet thing is in file b. #
#----------------------------------------------------------------------#
packets=$( awk '/packets input/ { print $4 }' b )

errors=$( awk '/input errors/ { print $1, $4, $6, $8, $12 }' b )

decode=$( awk '/decode/ { print $1 }' b )

#----------------------------------------------------------------------#
# Print some legible output. #
#----------------------------------------------------------------------#
echo For $line . . .
echo packets: $packets
echo errors: $errors
echo decode: $decode
echo =-------------------------------------

done

Obviously modifiy the echo's however you'd like.

Hey, even better. Just use all ksh:

while read line ; do

if [[ $line = *Ethernet* ]]; then
ethernet="$line"
fi

if [[ $line = *packets*input* ]]; then
packets="$line"
fi

if [[ $line = *input*errors* ]]; then
errors="$line"
fi

if [[ $line = *decode* ]]; then
decode="$line"
fi

if [[ $line = *output*queue* ]]; then

#----------------------------------------------------------------------#
# Print some legible output. #
#----------------------------------------------------------------------#
echo For $ethernet . . .
echo packets: $packets
echo errors: $errors
echo decode: $decode
echo =-------------------------------------
fi

done < original_log_file

Thanks so much quirkasaurus. Your first reply was very helpfull thanks. The hint to use more is great. YOU THE MAN...