awk - use double NOT in search


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk - use double NOT in search
# 1  
Old 09-25-2009
Question awk - use double NOT in search

Hi folks,

Can someone guide me on how to use two "not" in an awk search function?

What would be equivalent to
grep ABCD file | grep TO | grep -v "#" | grep -v "DR" in awk
(my idea is to use TWO && and TWO !)

Thanks a bunch in advance.
# 2  
Old 09-25-2009
can you post your input and desired output? it might be easier this way
# 3  
Old 09-25-2009
hi gowri didn't get you.. can u give some eaxmple...
u mean like
Code:
awk '!/hi/&&!/there/&&/you/{print}' filename

this will print all lines where there is no hi and there
# 4  
Old 09-25-2009
Hi Vidyadhar,

Great. That worked. Thanks.
I was using /&!/ and was not getting the desired result.

Hi Ryandegreat25 - thanks for your time.
# 5  
Old 09-25-2009
Quote:
Originally Posted by gowri_g_s
Code:
grep ABCD file | grep TO | grep -v "#" | grep -v "DR"

Code:
awk '/ABCD|TO/ &&! /#|DR/' file

# 6  
Old 09-25-2009
Quote:
Originally Posted by danmero
Code:
awk '/ABCD|TO/ &&! /#|DR/' file

Need records with ABCD and TO
Code:
awk '/ABCD/ && /TO/ && ! /#|DR/' file

Jean-Pierre.
# 7  
Old 09-25-2009
Ops Smilie right.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies

2. Shell Programming and Scripting

awk variable search and line count between variable-search pattern

Input: |Running the Rsync|Sun Oct 16 22:48:01 BST 2016 |End of the Rsync|Sun Oct 16 22:49:54 BST 2016 |Running the Rsync|Sun Oct 16 22:54:01 BST 2016 |End of the Rsync|Sun Oct 16 22:55:45 BST 2016 |Running the Rsync|Sun Oct 16 23:00:02 BST 2016 |End of the Rsync|Sun Oct 16 23:01:44 BST 2016... (4 Replies)
Discussion started by: busyboy
4 Replies

3. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

4. UNIX for Dummies Questions & Answers

Awk search help

Hi, Want to know what does it returns. $ awk '$1 == /Jan/' inv $ awk '$1 = /Jan/' inv --- What does this one signify. 1 13 25 15 115 1 21 36 64 620 $ awk '$1 ~ /Jan/' inv Jan 13 25 15 115 Jan 21 36 64 620 Thanks in advance. (3 Replies)
Discussion started by: vanand420
3 Replies

5. Shell Programming and Scripting

Replace double double quotes using AWK/SED

Hi, I have data as "01/22/97-"aaaaaaaaaaaaaaaaa""aaa""aabbbbbbbbcccccc""zbcd""dddddddddeeeeeeeeefffffff" I want to remove only the Consequitive double quotes and not the one which occurs single. My O/P must be ... (2 Replies)
Discussion started by: Bhuvaneswari
2 Replies

6. Shell Programming and Scripting

awk search if else

Hi, I want to search for a particular string using awk and print "Found" or "Not Found" depending on the search. On searching this forum i got this code but it is not working: (6 Replies)
Discussion started by: rishav
6 Replies

7. Shell Programming and Scripting

Using double quotes in awk

Hi I read somewhere that when using double quotes in awk; variables gets expanded else it doesn't. So I tried to use the double quotes inside an awk statement as below: from_instance_trans=`awk "/INPUT =\"$frm_inst\"/,/<\/TRANSFORMATION>/" $xml_object | grep -w "<TRANSFIELD" | awk... (9 Replies)
Discussion started by: dips_ag
9 Replies

8. Shell Programming and Scripting

awk search

i guys, i have a bash script , and it works, but i need an awk file, and i can't convert this code like: #!/bin/awk -f ..... my script #!/bin/bash awk '/\<FIRST\>|\<SECOND\>|\<THIRD\>|\<ZERO\>/' DOC.txt thanks :) (4 Replies)
Discussion started by: felito
4 Replies

9. Shell Programming and Scripting

AWK double delimiter

Hello, an awk style question (or a stupid question... it depends on your point of view :) ) How can I write in one awk command these two ones ? $USER - `grep $USER /etc/passwd | awk -F: '{ print $5 }' | awk -F, '{ print $1 }'` Thanks gb (4 Replies)
Discussion started by: gogol_bordello
4 Replies

10. Shell Programming and Scripting

Double search and replace?

I need to search for a line containing only 'XYY' or '//'. Then if the next line is either 'COD' or 'FAL' I need to replace positions 3-5 of the line 2 lines after that depending on its value. So my incoming file is like this: ABC XYZ COD AS/12/1436/02MAR09 K 99X C4347 N6450SDQ... (9 Replies)
Discussion started by: prismtx
9 Replies
Login or Register to Ask a Question