Re: A bit more difficult than usual questions
- From: Janis Papanagnou <janis_papanagnou@xxxxxxxxxxx>
- Date: Fri, 13 May 2011 16:58:12 +0200
Am 13.05.2011 16:14, schrieb gpadu99:
On May 13, 4:06 pm, Icarus Sparry<i.sparry...@xxxxxxxxx> wrote:On Fri, 13 May 2011 06:57:21 -0700, gpadu99 wrote:Hi all,
I would like to replace a string in a number of files. The problem is
that the string to find is different than what I want to replace. More
clearly: I want to find all instances of string "ABBB.C" and I want to
replace "BBB" with "DDD". That means that after the operation, all my
files should contain the string "ADDD.C"
Any tips are much appreciated
Your question is not very clear! You can replace ABBB.C with ADDD.C and
that will do what you want. If you are trying to suggest that the "A" and
".C" parts are variable then it might be that you want to look at "back-
references". e.g. using 'sed'
sed 's/\(A\)BBB\(\.C\)/\1DDD\2/' oldfile> newfile
Actually, I described the problem very badly. Yes actuall "A" and "C"
are "variables", in the sense that vary, they could be something else.
So, if I understood your example well, my search expression would be:
sed 's/[\.\ %(,'\''].*AAA[1-9]$/\1BBB\2/g'
Providing some ad hoc regexp string without telling what you want
is useless here.
Is it correct as I wrote it?
I doubt it (for many reasons). If Icarus' guess was right then use
Icarus' solution, if you intended something different then explain
your intention.
A couple samples of the sort "what shall be replaced" and some
samples "what shall not be replaced (and why not)" would help us
to support you.
Janis
Thank you very much for the guidance
.
- References:
- A bit more difficult than usual questions
- From: gpadu99
- Re: A bit more difficult than usual questions
- From: Icarus Sparry
- Re: A bit more difficult than usual questions
- From: gpadu99
- A bit more difficult than usual questions
- Prev by Date: see this video Shop Owner is pressing boobs of Lady tailor in shop
- Next by Date: The CIA are now studying Osama's hard drives. - - - Will Osama bin Laden become a Moslem Joan of Arc?
- Previous by thread: Re: Your sig
- Next by thread: Re: A bit more difficult than usual questions
- Index(es):
Relevant Pages
|