Help in loop find question at STEP 3


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in loop find question at STEP 3
# 1  
Old 01-27-2009
Help in loop find question at STEP 3

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


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
# Grep
cat $FILE | grep "Ethernet.* "\"\" | awk '{print $2 " " $3}' > searchfile

OUTPUT
Ethernet0/1 "",
Ethernet0/3 "",

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

Urgent help needed.
THANKS IN ADVANCE
# 2  
Old 01-27-2009
Just to clarify:

1. A "SHOW RUN" is done on the device in question. This creates an output file called MAINFILE which now has a copy of the running configuration of the device in question.

2. A secondary temp file (SEARCHFILE) is created by searching MAINFILE to find specific strings. This secondary file simply keeps a list of all the entries in the MAINFILE that conform to the search made.

3. I now need to write a script which will check SEARCHFILE and then take each specific entry in there and use that entry to search the MAINFILE.

4. Once found, it then needs to print the line found 15 lines below the searched string in the MAINFILE, creating a final output file called OUTPUTFILE.

5. Once complete, it then needs to check SEARCHFILE again to see if there are more entries to be searched in MAINFILE.

6. Each search needs to append the information found (15 lines below the entry in MAINFILE) onto the OUTPUTFILE.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Slowly Removing Bold Font Style - Step-by-Step

FYI, I'm slowly removing a lot of the bold font-styles from titles of discussions, forum titles, etc I'm not removing bold for the entire site because we do need bold from time to time, especially in posts and sometimes in other places. However, the original forum style had way too much... (3 Replies)
Discussion started by: Neo
3 Replies

2. UNIX for Advanced & Expert Users

Test shell script step by step?

Hi to all, I don't know if someone has done sometime a MS Excel Macro, that allows us to press F8 over the code to see step by step, to mention something, how is running the code, which values take the variables, if some loop is executing correct or where a error occurs, and some other... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

3. Linux

May you explain step by step where and how I will add pseudo code

Thank all of you. May you explain step by step where and how I will add pseudo code Note : I have Linux 2.6.24-26-server on x86_64 dears kindly help me (3 Replies)
Discussion started by: nonowa
3 Replies

4. UNIX for Dummies Questions & Answers

looking for step by step emacs c++ debug tutorial

Hello all i was searching the net for simple but effective tutorial to show me how debug c++ in emacs with not much luck. im not new to unix but new to emacs , i looking for tutorial that shows how to debug ( if possible ) c++ programs . LIike IDE suppose to , break points step in/out variable... (0 Replies)
Discussion started by: umen
0 Replies

5. Shell Programming and Scripting

works step by step on command line but not in script

Hi all, The following script is fine when I work via command line m=1 c=0 while do echo $m gnokii --getsms IN $m > out.txt; m=`expr $m + 1`; cat out.txt >> message_log; ############ read first crap< <(sed -n '/Text:/{n;p;}' out.txt); read message< <(sed -n '/Text:/{n;p;}'... (2 Replies)
Discussion started by: whamchaxed
2 Replies

6. UNIX for Dummies Questions & Answers

Step by step Installation of Unix SCO 2.1

I am new to unix and server at my job crashed due to hardware problem. I'm now opted to install sco unix on a new server - could anybody help me with the steps I need to take (pretty old machine) Thanks & Regards Nancy :( (0 Replies)
Discussion started by: nensee7
0 Replies

7. UNIX for Dummies Questions & Answers

install of sco unix step by step

HI I am new to unix and need to install sco unix on a new server - could anybody help me with the steps I need to take - the hd is a 9gb scsi drive (pretty old machine) Thanks (1 Reply)
Discussion started by: porikamu
1 Replies
Login or Register to Ask a Question