I'll try to be as clear as possible and hopefully you will get the idea
Code:
# cat file
============
Sending a signal to clean up NOT THREADED FMP process:
DATA #2 : ABCO_PID, PD_TYPE_PID, 4 bytes
11649230
============
Code:
# awk ' # Start awk script
/Sending a signal/{ # Select/grep for lines that have "pattern"
x=$0 # hold the line ( $0 ) on variable x
getline # get next line ... I don't care about
getline # get next line, that's what I want and ...
print x, $0 # now print the line on hold (x) and current line ( $0 ), we don't need printf(print format) now.
} # end awk script , see output.
' file
Output:
Code:
Sending a signal to clean up NOT THREADED FMP process: 11649230
PS: Use code tags when you post code or data sample.
Last edited by danmero; 03-13-2009 at 02:46 AM..
Reason: + PS
So we need to delete lines 2, 5, 8 -- every third line beginning with 2. The is a special notation for this in GNU sed. From there, we can paste the pairs of lines together to combine them. (In some versions of grep, a "--" line is inserted that we need to eliminate.)
Here is a script that does that:
Code:
#!/usr/bin/env bash
# @(#) s1 Demonstrate a window match and extraction.
echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) grep sed paste
set -o nounset
echo
FILE=${1-data1}
echo " Data file $FILE:"
cat $FILE
echo
echo " Results:"
grep -A2 'Sending SIGKILL' $FILE |
tee t1 |
grep -v -e '^--$' |
tee t2 |
sed '2~3d' |
tee t3 |
paste - -
exit 0
producing:
Code:
% ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.11-x1, i686
Distribution : Xandros Desktop 3.0.3 Business
GNU bash 2.05b.0
grep (GNU grep) 2.5.1
GNU sed version 4.1.2
paste (coreutils) 5.2.1
Data file data1:
2009-01-19-01.19.24.816169+660 I8635A1158 LEVEL: Error
PID : 5873782 TID : 1 PROC : aaaa
APPHDL : 0-269
AUTHID : PDBCMPC
FUNCTION: bbbb
MESSAGE : Sending SIGKILL to the following process id
DATA #1 : signed integer, 4 bytes
13287492
CALLSTCK:
2009-01-19-01.19.24.816169+660 I8635A1158 LEVEL: Error
PID : 5873782 TID : 1 PROC : aaaa
APPHDL : 0-269
AUTHID : PDBCMPC
FUNCTION: bbbb
MESSAGE : Sending SIGKILL to the following process id
DATA #1 : signed integer, 4 bytes
99999999
CALLSTCK:
Results:
MESSAGE : Sending SIGKILL to the following process id 13287492
MESSAGE : Sending SIGKILL to the following process id 99999999
I added an extra segment to the data to ensure correctness of the script. I also added tee commands in case you want to see the intermediate results. They can be removed for a production script ... cheers, drl
Hi all!
Thanks for taking the time to view this!
I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern.
Example:
Drink a soda
Eat a banana
Eat multiple bananas
Drink an apple juice
Eat an apple
Eat multiple apples
I... (8 Replies)
Hi ,
I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows.
# diff mir_lex.c.modified mir_lex.c.orig
3209c3209
< if(yy_current_buffer -> yy_is_our_buffer == 0) {
---
>... (5 Replies)
Hi,
I have a file monitor.txt as below...
# Times are converted to local time from GMT.
# Local Timezone: EST (GMT -05:00)
PARAM1
{
TIME 30;
CC1 "xxxxx";
CC2 "xxxxx";
CC3 "xxxxx";
CC4 "xxxxx";
}
PARAM2
{
4061 :... (3 Replies)
Hi,
When we have a failure, sometimes we just step restart the job from the next step. Later when we open the log for analysis of the failure, it is becoming difficult to go to the failure part.
For eg., if it is a 1000 line log, the failure may be at 500th line. so wat i want to do is, grep... (6 Replies)
I have created a dummy file -demo.txt
On my machine-A (oslevel-5300-08) I can display the file content in HEX format through VI editor using :%!xxd but on other machine-B (oslevel - 5300-06) , I get error as "sh: xxd: not found."
machine-A:
$ cat demo.txt
Hello World !
I can display... (7 Replies)
Suppose I have two files 1.txt and 2.txt.
My aim is to find (Total execution time/Number of executions)
then sort the result as in decreasing order.
Can anyone provide me any shell/perl/awk script or a Command to do that in faster way ?
1.txt :
===============================
Number of... (4 Replies)
Unix Gurus,
I have been breaking my head to get this done..seems simple..
I need to read a flat file and based on a key word in a line, i need to skip the previous 3 lines.
eg :
Line1
Line2
Line3
Line4
Line5
Line6
Error
Line7
Line8
Line9
Error
Line10 (4 Replies)
I am having a problem here. We are having several problems in regards to hung process's on unix (HPUX box), caused by my RF equipment (Mobile data capture units). these contact the host via a simply telnet session and locks the system?
Is it a timeout problem as the timeout is disabled on the host. (5 Replies)