grep XXX that not followed by YYY


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep XXX that not followed by YYY
# 1  
Old 06-10-2008
grep XXX that not followed by YYY

I want to grep all lines containing blocking sess= that are not followed by 0x0
Code:
cat trace.log
blocking sess=0x0
blocking sess=0x0
rrrr......
blocking sess=121
blocking sess=0x0
blocking sess=0x0
blocking sess=0x0
some other lines
blocking sess=001
blocking sess=0x0
blocking sess=0x1

the grep output should be

Code:
blocking sess=121
blocking sess=001
blocking sess=0x1

any idea ?

Last edited by ynixon; 06-10-2008 at 10:26 AM..
# 2  
Old 06-10-2008
I seems that in your file you have only lines in the form "blocking sess=XxY"... So:

Code:
grep -v "blocking sess=0x0" trace.log

# 3  
Old 06-10-2008
Quote:
Originally Posted by robotronic
I seems that in your file you have only lines in the form "blocking sess=XxY"... So:

Code:
grep -v "blocking sess=0x0" trace.log

you are right, the example was wrong... I fixed the example see above
# 4  
Old 06-10-2008
grep -v "0x0" trace.log
# 5  
Old 06-10-2008
Go with the "dirty and simple way":

Code:
grep -v "blocking sess=0x0" trace.log | grep "blocking sess"

Or try something different:

Code:
awk -F"=" '/blocking sess=/ && $2 != "0x0"' trace.log

# 6  
Old 06-10-2008
With Sed:

Code:
sed -n '/=0x0/!{/blocking sess=/p;}' trace.log


Last edited by radoulov; 06-10-2008 at 11:02 AM..
# 7  
Old 06-10-2008
Quote:
Originally Posted by navi
grep -v "0x0" trace.log
This will not filter the lines with "rrrr......" and "some other lines" Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Gnome3 locksup on new Linux kernel 12.6.xxx & 12.5.xxx

Hi Forum Ive been having a problem with the kernal(s) for some strange reason it every time I try and access the date and time/calendar or system settings it locks up the whole laptop and nothing responds. :(. This doesn't happen 11.10.xxx kernel . Any help would be much appreciated and thank you... (1 Reply)
Discussion started by: ShinTec
1 Replies

2. Shell Programming and Scripting

Extracting entries starting with xxx

Hello, I am trying to extract all words (entries) from a file beginning with 123. For example: ververv ewfaafa 123asd 4334j fdgfgf fdfdssd 123890 xxxxx eeee sss 1234 sdfsf were sfs fbdsdfb fsdg sdgfsd bfg sdfb dsfb sdfg sdf ergerg 123pop sdfgdfg 123ww 123qq dffg Desired output: 123asd... (4 Replies)
Discussion started by: palex
4 Replies

3. Shell Programming and Scripting

Kill all proceess with the name XXX

Hello guys, I have a problem. How can i "kill -9" with the name process? I have a lot of process with the same name, but i do not want kill each one with the process ID. There is a comand to "kill -9" al process with name "XXXX". Thanks! (5 Replies)
Discussion started by: Xedrox
5 Replies

4. AIX

echo $varibla | mail -s "subject" "xxx@xxx.com" not ruuning as expected

Hi Folks, As per the subject, the following command is not working as expected. echo $variable | mail -s "subject" "xxx@xxx.com" Could anyone figure it out whats wrong with this. I am using AIX box. Regards, (2 Replies)
Discussion started by: gjarms
2 Replies

5. UNIX for Dummies Questions & Answers

How to grep value with "xxx"

Hi, I don't know how to grep two value with "" in the file, anyone can help? for example: the text file John cash "1234" "ok" may card "1245" "unknown" John card "4567" "ok" may cash "1111" "ok" may card "1234" "ok" peter card "1234" "ok" John card "1234" "ok" I would like to grep... (4 Replies)
Discussion started by: happyv
4 Replies

6. Shell Programming and Scripting

tail -XXX with grep doesn't work in while loop

Hi all, I need some help. my shell script doesn't work especially in the loop. #!/bin/sh -xv export ORA_ADMIN=/oracle/home/admin export ORACLE_SID=ORA_SID cat ${ORA_ADMIN}/param_alert_log.ora | while read MSG do #echo $MSG #echo "tail -400... (8 Replies)
Discussion started by: sidobre
8 Replies

7. AIX

xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?

AIX 4.2 I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works... (2 Replies)
Discussion started by: Browser_ice
2 Replies

8. UNIX for Dummies Questions & Answers

xxx.tar.gz error

Hi All, We have taken data backup using gzip but when we try to restore from ex:xxx.tar.gz file got below error. invalid compressed data--crc error and invalid compressed data--length error How to recover my original data. Thanks in advance for your suggestion (1 Reply)
Discussion started by: bache_gowda
1 Replies

9. Shell Programming and Scripting

Delete a file from XXX.tar.Z

Hi All can u please let me know how to delete a file from XXX.tar.Z file with out uncompressing this file. thanks in advance. --Bali (0 Replies)
Discussion started by: balireddy_77
0 Replies
Login or Register to Ask a Question