For Programmers: Free Programming Magazines  


Home > Archive > AWK > January 2008 > awk & shell variables containing blanks









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author awk & shell variables containing blanks
Mark

2008-01-17, 9:59 pm

Hi,

Currently I am experiencing a small issue with awk search patterns & korn
shell variables.
I simplified my problem to the following example (which will explain itself
I suppose) :

$ x="a b"
$ awk '/'$x'/' <file>
awk: line 1: runaway regular expression /a ...

Can anyone tell me how to get around it? Probably a small thing, but I
can't seem to find the answer ...


Thanks!

Mark

AGT

2008-01-17, 9:59 pm

On Fri, 18 Jan 2008, Bob Harris wrote:

> In article <478fe20b$0$70962$dbd4d001@news.wanadoo.nl>,
> "Mark" <huijstee@hotmail.com> wrote:
> awk -v re="$x" '$0 ~ re { do something }' file
> If you are using Sun, then look for nawk on your system, or get
> gawk and install it.


Some people cannot just install things where ever whenever they please.
So there is also /usr/xpg4/bin/awk.
Unless your Solaris OS version dates WAY back.

--
All email to this account is /dev/nulled

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com