A SED script

Giorgos Keramidas keramida at ceid.upatras.gr
Sat Jun 26 12:52:33 PDT 2004


On 2004-06-26 12:08, antenneX <antennex at 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



More information about the freebsd-questions mailing list