Re: search for charater "="
- From: pk <pk@xxxxxxxxxx>
- Date: Mon, 05 May 2008 09:49:23 +0200
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.
.
- Follow-Ups:
- Re: search for charater "="
- From: Nezhate
- Re: search for charater "="
- References:
- search for charater "="
- From: Nezhate
- search for charater "="
- Prev by Date: search for charater "="
- Next by Date: Re: search for charater "="
- Previous by thread: search for charater "="
- Next by thread: Re: search for charater "="
- Index(es):
Relevant Pages
|