No problem. It is better to make the code more readable:
Code:
awk '
/UDP flood/{ --> match lines with UDP flood
flood=$0; --> copy it for later
if(line){ --> if variable "line" is not empty
print line ORS $0; --> print it and the current line
line="" --> reset the "line" variable
}
}
!/UDP flood/{ --> match lines not UDP flood
line=$0; --> copy it for later
if(flood){ --> if variable "flood" is not empty
print flood ORS $0; --> print it and the current line
flood="" --> reset the "flood" variable
}
}' file
The 1st block saves UDP flood lines and prints the last line that was not UDP flood - the one immediately before it.
The 2nd block saves lines that are not UDP flood and prints the last UDP flood line - the one immediately before it.
Each block works together to match any lines before and after the UDP flood one.
Note that the ORS is the Output Record Seperater which defaults to a newline.
Hi all,
I need help in following scenario. I have a file with about 10,000 lines. There are several lines which have word "START" (all upper case) in them. I want to grep line with word "START" and then do the following
1. Print the line number having word "START"
2. Print the next 11 lines.
... (4 Replies)
Hi folks
I am not allowed to install GNU grep on AIX.
Here my code excerpt:
grep_fatal () {
/usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP"
}
Howto the same on AIX based machine?
from manual GNU grep
‘--after-context=num’
Print num lines of trailing context after... (4 Replies)
I have several very large file that are extracts from Oracle tables. These files are formatted in XML type syntax with multiple entries like:
<ROW>
some information
more information
</ROW>
I want to grep for some words, then print all lines between <ROW> AND </ROW>. Can this be done with AWK?... (7 Replies)
Hi,
i would like to get the above and below lines of the grep pattern .
For ex :
file as below:
chk1- aaaa
1-Nov
chk2 -aaaa
##########
chk1-bbbbbb
1-Nov
chk2-bbbbbb
#########
my search pattern is date : 1-Nov
i need the o/p as below
chk1- aaaa
1-Nov (6 Replies)
Hi All,
I need to grep through a file for a string and print the next ten lines to a file separating the lines with a , and save it as a csv file to open it as a XL file. The 10 lines should be on a sigle row in xl.
Any suggesstions please.
Note; I dont have a GNU Grep to use -A flag.
... (6 Replies)
RHEL 5.8
I have a text file like below. I want to grep for a string and then print the next 4 lines including the line with the string I grepped for
For eg:
I want grep for the string HANS and then print the next 4 lines including HANS
$ cat someText.txt
JOHN
NATIONALITY:... (7 Replies)
Hi all,
I am struck with the below requirement. I need to grep a particular pattern in a file and then print next n lines of it for further processing.
I have used the below code
grep -A 3 "pattern" filename
But it is throwing error as below.
grep: illegal option -- A
Can... (14 Replies)
Hi ,
My record file , need to print up to above (DATA array)(there may be n no lines ) , grep "myvalue" row now .....suggest me some options
--- DATA Array---
record type xxxxx
sequence type yyyyy
2
3---> data1
/dev/
--- DEVICE ---
MAXIMUM_People=
data_blocks=
MY_value=2
xyz
abc ... (0 Replies)
Hi All,
I am having a text file like below
ERROR - Not a valid
ID : 123
ERROR - Not a valid
hello
ID : 124
SUCCESS - Valid
ID : 12
I need to display like below after reading the file if it finds the error keyword
along with displaying this first line when error pattern... (10 Replies)
Discussion started by: rohit_shinez
10 Replies
LEARN ABOUT SUNOS
mlib_graphicsfloodfill_32
mlib_GraphicsFloodFill_8(3MLIB) mediaLib Library Functions mlib_GraphicsFloodFill_8(3MLIB)NAME
mlib_GraphicsFloodFill_8, mlib_GraphicsFloodFill_32 - flood fill
SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ]
#include <mlib.h>
mlib_status mlib_GraphicsFloodFill_8(mlib_image *buffer, mlib_s16 x, mlib_s16 y, mlib_s32 c, mlib_s32 c2);
mlib_status mlib_GraphicsFloodFill_32(mlib_image *buffer, mlib_s16 x, mlib_s16 y, mlib_s32 c, mlib_s32 c2);
DESCRIPTION
Each of these functions performs flood fill.
PARAMETERS
Each of the functions takes the following arguments:
buffer Pointer to the image into which the function is drawing.
x X coordinate of the starting point.
y Y coordinate of the starting point.
c Color used in the drawing.
c2 Color that defines the filling interior.
RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO attributes(5)SunOS 5.10 9 Nov 2004 mlib_GraphicsFloodFill_8(3MLIB)