Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: awk & shell...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 2133 of 2376
Post > Topic >>

Re: awk & shell variables containing blanks

by Bob Harris <nospam.News.Bob@[EMAIL PROTECTED] > Jan 18, 2008 at 01:08 AM

In article <478fe20b$0$70962$dbd4d001@[EMAIL PROTECTED]
>,
 "Mark" <huijstee@[EMAIL PROTECTED]
> wrote:

> 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 

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.

                                        Bob Harris
 




 4 Posts in Topic:
awk & shell variables containing blanks
"Mark" <huij  2008-01-18 00:17:29 
Re: awk & shell variables containing blanks
Janis Papanagnou <Jani  2008-01-18 00:42:59 
Re: awk & shell variables containing blanks
Bob Harris <nospam.New  2008-01-18 01:08:22 
Re: awk & shell variables containing blanks
AGT <gerryt2@[EMAIL PR  2008-01-17 19:43:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 8:03:22 CDT 2008.