# negate \* with in pattren matching...

**URL:** <https://community.unix.com/t/negate-with-in-pattren-matching/171918>\
**Category:** Shell Programming and Scripting\
**Created:** [June 11, 2007, 7:51am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918 "2007-06-11T07:51:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbsrinivas](https://community.unix.com/letter_avatar/pbsrinivas/32/5_5575768a8748004e209b776fc1b2916d.png) [@pbsrinivas](https://community.unix.com/u/pbsrinivas)\
**Post date:** [June 11, 2007, 7:51am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/1 "2007-06-11T07:51:00Z")

</div>

Hi Every one

I have a file in the following manner...

AAAAAA_PERFORM WRITEQ  
BBDFDD_PERFOMF WRITEQ  
FFFF \*PERFOMF WRITEQ

i want to find the lines which donot have \* in 7th position..

I have tried this but some problem i think...

grep '......[^\*][.]\*WRITEQ' INpFIle...

any 6 chars not followed by \* and any char followed by WRITEQ

but this gets me everyting... including 7th char as \*

---

<div class="post-metadata">

**Author:** ![aigles](https://community.unix.com/user_avatar/community.unix.com/aigles/32/118_2.png) [@aigles](https://community.unix.com/u/aigles)\
**Post date:** [June 11, 2007, 7:57am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/2 "2007-06-11T07:57:12Z")

</div>

Try this :

```nohighlight
grep -v '^......\*.*WRITEQ' infile

```

Jean-Pierre.

---

<div class="post-metadata">

**Author:** ![anbu23](https://community.unix.com/user_avatar/community.unix.com/anbu23/32/351_2.png) [@anbu23](https://community.unix.com/u/anbu23)\
**Post date:** [June 11, 2007, 7:57am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/3 "2007-06-11T07:57:36Z")

</div>

```nohighlight
grep '^.\{6\}[^*].*WRITEQ' filename

```

```nohighlight
sed -n '/^.\{6\}[^*].*WRITEQ/p' filename

```

---

<div class="post-metadata">

**Author:** ![pbsrinivas](https://community.unix.com/letter_avatar/pbsrinivas/32/5_5575768a8748004e209b776fc1b2916d.png) [@pbsrinivas](https://community.unix.com/u/pbsrinivas)\
**Post date:** [June 11, 2007, 8:03am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/4 "2007-06-11T08:03:59Z")

</div>

thanks Jean-Pierre, Anbu

It works....

---

<div class="post-metadata">

**Author:** ![pbsrinivas](https://community.unix.com/letter_avatar/pbsrinivas/32/5_5575768a8748004e209b776fc1b2916d.png) [@pbsrinivas](https://community.unix.com/u/pbsrinivas)\
**Post date:** [June 11, 2007, 8:52am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/5 "2007-06-11T08:52:30Z")

</div>

> [@pbsrinivas](#):
>
> thanks Jean-Pierre, Anbu
> 
> It works....

Small Help

My inp file is

TSQGN8\* MOVE 'WRITEQ ERROR' TO MSG-FIELDO  
\*  
MOVE 1 TO WS-TS-ITEM.  
\*\*\*\*\*\*\* CHANGE FOR CICS END\*\*\*\*\*\*\*  
EXEC CICS WRITEQ TS QUEUE  
ABCD  
EFGH  
END-EXEC.

I am using the following

awk '/^.\{6\}[^\*].\* WRITEQ /,/END-EXEC/' InpFile

I wanted to find the line Between WRITEQ and END-EXEC  
Provided WRITEQ is no Commented and has one space before and after

the Out put should be

```
       EXEC CICS WRITEQ TS QUEUE
       ABCD
       EFGH
       END-EXEC.

```

but i dont now it fails....

---

<div class="post-metadata">

**Author:** ![ghostdog74](https://community.unix.com/letter_avatar/ghostdog74/32/5_5575768a8748004e209b776fc1b2916d.png) [@ghostdog74](https://community.unix.com/u/ghostdog74)\
**Post date:** [June 11, 2007, 8:52am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/6 "2007-06-11T08:52:30Z")

</div>

another way

```nohighlight
awk 'BEGIN{FS=""}$7 != "*"' file

```

---

<div class="post-metadata">

**Author:** ![pbsrinivas](https://community.unix.com/letter_avatar/pbsrinivas/32/5_5575768a8748004e209b776fc1b2916d.png) [@pbsrinivas](https://community.unix.com/u/pbsrinivas)\
**Post date:** [June 11, 2007, 9:08am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/7 "2007-06-11T09:08:56Z")

</div>

> [@pbsrinivas](#):
>
> TSQGN8\* MOVE 'WRITEQ ERROR' TO MSG-FIELDO  
> \*  
> MOVE 1 TO WS-TS-ITEM.  
> \*\*\*\*\*\*\* CHANGE FOR CICS END\*\*\*\*\*\*\*  
> EXEC CICS WRITEQ TS QUEUE  
> ABCD  
> EFGH  
> END-EXEC.

the following worked...

awk '/^......[^\*].\*WRITEQ/,/END-EXEC/p' temp

Thanks,,,

---

<div class="post-metadata">

**Author:** ![pbsrinivas](https://community.unix.com/letter_avatar/pbsrinivas/32/5_5575768a8748004e209b776fc1b2916d.png) [@pbsrinivas](https://community.unix.com/u/pbsrinivas)\
**Post date:** [June 11, 2007, 9:30am UTC](https://community.unix.com/t/negate-with-in-pattren-matching/171918/8 "2007-06-11T09:30:35Z")

</div>

wrong Question...
