Search replace doubt

Hi,
I hav got a text file with contents

jkfsflkfd ;
lsfjsdlflf ;
kjsflkfds ;
lksjfdkjf ;


i need to replace all ; with some text (containing characters also)

does tr work??


Thanks in advance
Anup V [ Fr, 01 Februar 2008 18:58 ] [ ID #1921521 ]

Re: Search replace doubt

varkey [at] changingideas.com wrote:
>
> I hav got a text file with contents
>
> jkfsflkfd ;
> lsfjsdlflf ;
> kjsflkfds ;
> lksjfdkjf ;
>
>
> i need to replace all ; with some text (containing characters also)
>
> does tr work??

no.

sed "s/;/some text/" textfile

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 01 Februar 2008 19:05 ] [ ID #1921522 ]

Re: Search replace doubt

On Fri, 01 Feb 2008 19:05:49 +0100, Cyrus Kriticos wrote:
> varkey [at] changingideas.com wrote:
>>
>> I hav got a text file with contents
>>
>> jkfsflkfd ;
>> lsfjsdlflf ;
>> kjsflkfds ;
>> lksjfdkjf ;
>>
>>
>> i need to replace all ; with some text (containing characters also)
>>
>> does tr work??
>
> no.
>
> sed "s/;/some text/" textfile

And, no, _THAT_ doesn't work either!

$ sed "s/;/some text/g" textfile

Used the "g" because the OP said "all ;"....

Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | [at] config.com | Jonesy | OS/2
*** Killfiling google posts: <http://jonz.net/ng.htm>
Allodoxaphobia [ Fr, 01 Februar 2008 19:11 ] [ ID #1921523 ]

Re: Search replace doubt

Allodoxaphobia wrote:
> On Fri, 01 Feb 2008 19:05:49 +0100, Cyrus Kriticos wrote:
>> varkey [at] changingideas.com wrote:
>>> I hav got a text file with contents
>>>
>>> jkfsflkfd ;
>>> lsfjsdlflf ;
>>> kjsflkfds ;
>>> lksjfdkjf ;
>>>
>>>
>>> i need to replace all ; with some text (containing characters also)
>>>
>>> does tr work??
>> no.
>>
>> sed "s/;/some text/" textfile
>
> And, no, _THAT_ doesn't work either!
>
> $ sed "s/;/some text/g" textfile
>
> Used the "g" because the OP said "all ;"....

The OP said "all ;" but the "g" is not necessary.

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 01 Februar 2008 19:41 ] [ ID #1921525 ]

Re: Search replace doubt

On Fri, 01 Feb 2008 19:41:03 +0100, Cyrus Kriticos wrote:
> Allodoxaphobia wrote:
>> On Fri, 01 Feb 2008 19:05:49 +0100, Cyrus Kriticos wrote:
>>> varkey [at] changingideas.com wrote:
>>>> I hav got a text file with contents
>>>>
>>>> jkfsflkfd ;
>>>> lsfjsdlflf ;
>>>> kjsflkfds ;
>>>> lksjfdkjf ;
>>>>
>>>> i need to replace all ; with some text (containing characters also)
>>>>
>>>> does tr work??
>>> no.
>>>
>>> sed "s/;/some text/" textfile
>>
>> And, no, _THAT_ doesn't work either!
>>
>> $ sed "s/;/some text/g" textfile
>>
>> Used the "g" because the OP said "all ;"....
>
> The OP said "all ;" but the "g" is not necessary.

'Twould be if there are 2 ";" on a line.

Jonesy
Allodoxaphobia [ Fr, 01 Februar 2008 20:52 ] [ ID #1921527 ]
Linux » comp.unix.shell » Search replace doubt

Vorheriges Thema: What effect does "shopt -s extglob" has on "find" command in bash ?
Nächstes Thema: SFTP permissions