[Gllug] issues with awk

Alain Williams addw at phcomp.co.uk
Mon Sep 12 07:58:14 UTC 2011


On Mon, Sep 12, 2011 at 08:32:00AM +0100, dudes dudes wrote:

> However; if I script this in bash such as:
> 
> ip="127.0.0.1"
> 
> awk '$1==$ip {print}' test.txt
> 
> I never get the right results. 

$ip is in single quotes and so is not substituted by the shell.
The following might work (not tested):

	awk --assign ip=$ip '$1==$ip {print}' test.txt

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>
--
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list