Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jun 2004 21:40:08 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        antenneX <antennex@swbell.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: A SED script
Message-ID:  <20040626184008.GB1016@gothmog.gr>
In-Reply-To: <00ce01c45ba0$343ffc00$0200000a@SAGEAME>
References:  <00ce01c45ba0$343ffc00$0200000a@SAGEAME>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-06-26 12:08, antenneX <antennex@swbell.net> wrote:
> I cannot get it to work on another file (perl.pl file) to change the line:
> $OrderNumPrefix = "ATX060"; to $OrderNumPrefix = "ATX070";
>
> I suspect I'm not handling the quotes or other operators correctly and it
> just ignores the change.
>
> Here's the snippet of the script I'm trying to use:
> #!/bin/sh
> new=`grep -i new /path/to/newfile`
> old=`grep -i new /path/to/oldfile`
> sed -i.bak -e "s/$old/$new/" /path/to/myfile

The results depend heavily on the existence and contents of the two files
named /path/to/{old,new}file.  I'm sure if you change the sed line to:

    sed -i.bak -e 's/ATX060/ATX070/' /path/to/myfile

it will all work fine.

> What do I need to change to make it work....???

Something within oldfile or newfile, is a far reaching guess.

- Giorgos



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040626184008.GB1016>