Talk About Network



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: search for ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 13 Topic 2229 of 2236
Post > Topic >>

Re: search for charater "="

by pk <pk@[EMAIL PROTECTED] > May 5, 2008 at 09:49 AM

On Monday 5 May 2008 09:31, Nezhate wrote:

> Hi there
> I'm using awk to search the character equal "=" and replace it with
> space character " " in file1. The result is redirected to another
> file2.
> 
> ----------------file1-------------------
> field1="data1"after there is some data...
> field2="data2"after there is some data...
> field3="data3"after there is some data...
> field4="data4"after there is some data...
> -----------------end_file1---------------------
> 
> I used this
> awk 's/=/ ' file1 >> file2
> 
> but I get this error
> 
> awk: s/=/TEST
> awk:     ^ unterminated regexp
> 
> 
> I want to have the next file
> ----------------file2-------------------
> field1 "data1"after there is some data...
> field2 "data2"after there is some data...
> field3 "data3"after there is some data...
> field4 "data4"after there is some data...
> -----------------end_file2---------------------
> 
> how to indicate that I'm searching for character and not for an
> unterminated regular expression?
> Thanks for your help.

I think you are a bit confused here. You are using what looks like sed
syntax (although incorrect) as a command to awk. So, either do

sed 's/=/ /' file1

(this replaces only the first = in each line; if you want to replace all
=,
then use
sed 's/=/ /g' file1)

or, if you want to use awk, then do

awk 'sub(/=/," ")+1' file1

(again, this replaces only the first = in each line; if you want to
replace
all =, then do
awk 'gsub(/=/," ")+1' file1)

-- 
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.




 13 Posts in Topic:
search for charater "="
Nezhate <mazouz.nezhat  2008-05-05 00:31:15 
Re: search for charater "="
pk <pk@[EMAIL PROTECTE  2008-05-05 09:49:23 
Re: search for charater "="
Nezhate <mazouz.nezhat  2008-05-05 01:58:02 
Re: search for charater "="
pk <pk@[EMAIL PROTECTE  2008-05-05 11:11:28 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:21:02 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:25:51 
Re: search for charater "="
pk <pk@[EMAIL PROTECTE  2008-05-05 15:46:30 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:54:00 
Re: search for charater "="
gazelle@[EMAIL PROTECTED]  2008-05-05 13:56:33 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 09:26:17 
Re: search for charater "="
"Rajan" <rsh  2008-05-05 22:33:48 
Re: search for charater "="
Janis <janis_papanagno  2008-05-05 02:14:53 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:17:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Thu May 15 22:41:45 CDT 2008.