I haven't used awk much but a better way would be to do 'grep -v
patternyoudontwanttomatch'. maybe put quotes around the pattern or
something.
I can't sleep so I debugged the rest of it. This works properly:
 read var
 awk "\$0 !~ /$var/ {print}" file

paul
-- 
You can tune a piano, but you can't tuna fish.

You can tune a filesystem, but you can't tuna fish.
                -- from the tunefs(8) man page

On Tue, 23 May 2000, David Smith wrote:

> I'm writing a Bourne shell script, and I've run into a snag.
> I want to read in a variable and pass the string in that variable
> to awk.
> 
> Something like this:
> 
> read $var
> awk '$0 !~ /$var/ {print}' file
> 
> This deletes any line containing $var.  Unfortunately, it won't work
> as I have it because my quoting is wrong. I've tried all the
> permutations, and I'm stumped.  Can someone straighten me out?
> 
> This was my best attempt:
> 
> awk "'\$0 !~ /"$var"/ {print}" 
> 
> and I got the error "Invalid char ''' in expression."  It means
> the first '.
> 
> Also, is there a better way to selectively delete lines from input?
> 
> Thanks,
> Dave
> 
> ---------------------------------------------------------------------------
> Send administrative requests to [EMAIL PROTECTED]
> 


---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to