Sponsored Content
Top Forums Shell Programming and Scripting cat file1 read line-per-line then grep -A 15 lines down in fileb Post 302280561 by irongeekio on Tuesday 27th of January 2009 08:55:22 AM
Old 01-27-2009
found the 15 lines this work better.

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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using 'cat' to in 'while read line'

Hi, I'm having some trouble reading a file that was 'cat' through a while loop. Can anyone suggest alternatives? what i do is cat filename|grep *.stuff while read line do echo $line ... and other commands done The cat,grep line seems to work correctly, but the script hangs when i add in... (3 Replies)
Discussion started by: chugger06
3 Replies

2. Shell Programming and Scripting

Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies

3. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies

4. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

5. UNIX for Dummies Questions & Answers

Find a value inside file1 and replace it with another value from another fileB

i have a file with some data and i need replace a perticular value with some other value from another another file req: file1.txt abc,idle.txt,1234 file2.txt 5678 now the requirement is need to replace the "idle.txt" is with "mike_5678" here 5678 from file2.txt... file2.txt contains only... (2 Replies)
Discussion started by: dssyadav
2 Replies

6. Shell Programming and Scripting

Using regex's from file1, print line and line after matches in file2

Good day, I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after. file1: file2: Output: I can match a regex and print the line and line after awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } ' ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

7. Shell Programming and Scripting

Match single line in file1 to groups of lines in file2

I have two files. File 1 is a two-column index file, e.g. comp11084_c0_seq6:130-468(-) comp12746_c0_seq3:140-478(+) comp11084_c0_seq3:201-539(-) comp12746_c0_seq2:191-529(+) File 2 is a sequence file with headers named with the same terms that populate file 1. ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

8. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

9. Shell Programming and Scripting

Read the file line by line and do something with lines

I have a file file_name_O.txt The file can have different number of other files names or nothing I will check cnt=`wc -l file_name_0.txt` if ;then exit 1 fi Now I have to start checking file names, i.e. read txt file line by line. If amount of ,lines equal 1, I can... (4 Replies)
Discussion started by: digioleg54
4 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
PBFIFO(8)							       Linux								 PBFIFO(8)

NAME
pfifo - Packet limited First In, First Out queue bfifo - Byte limited First In, First Out queue SYNOPSIS
tc qdisc ... add pfifo [ limit packets ] tc qdisc ... add bfifo [ limit bytes ] DESCRIPTION
The pfifo and bfifo qdiscs are unadorned First In, First Out queues. They are the simplest queues possible and therefore have no overhead. pfifo constrains the queue size as measured in packets. bfifo does so as measured in bytes. Like all non-default qdiscs, they maintain statistics. This might be a reason to prefer pfifo or bfifo over the default. ALGORITHM
A list of packets is maintained, when a packet is enqueued it gets inserted at the tail of a list. When a packet needs to be sent out to the network, it is taken from the head of the list. If the list is too long, no further packets are allowed on. This is called 'tail drop'. PARAMETERS
limit Maximum queue size. Specified in bytes for bfifo, in packets for pfifo. For pfifo, defaults to the interface txqueuelen, as speci- fied with ifconfig(8) or ip(8). The range for this parameter is [0, UINT32_MAX]. For bfifo, it defaults to the txqueuelen multiplied by the interface MTU. The range for this parameter is [0, UINT32_MAX] bytes. Note: The link layer header was considered when counting packets length. OUTPUT
The output of tc -s qdisc ls contains the limit, either in packets or in bytes, and the number of bytes and packets actually sent. An unsent and dropped packet only appears between braces and is not counted as 'Sent'. In this example, the queue length is 100 packets, 45894 bytes were sent over 681 packets. No packets were dropped, and as the pfifo queue does not slow down packets, there were also no overlimits: # tc -s qdisc ls dev eth0 qdisc pfifo 8001: dev eth0 limit 100p Sent 45894 bytes 681 pkts (dropped 0, overlimits 0) If a backlog occurs, this is displayed as well. SEE ALSO
tc(8) AUTHORS
Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru> This manpage maintained by bert hubert <ahu@ds9a.nl> iproute2 10 January 2002 PBFIFO(8)
All times are GMT -4. The time now is 09:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy