From owner-freebsd-questions@FreeBSD.ORG Sat Jun 26 22:19:54 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0408E16A4CE for ; Sat, 26 Jun 2004 22:19:54 +0000 (GMT) Received: from mtaw6.prodigy.net (mtaw6.prodigy.net [64.164.98.56]) by mx1.FreeBSD.org (Postfix) with ESMTP id E7F5F43D2D for ; Sat, 26 Jun 2004 22:19:53 +0000 (GMT) (envelope-from antennex@swbell.net) Received: from SAGEAME (adsl-65-68-247-73.dsl.crchtx.swbell.net [65.68.247.73]) by mtaw6.prodigy.net (8.12.10/8.12.10) with SMTP id i5QMI8dH001433; Sat, 26 Jun 2004 15:18:11 -0700 (PDT) Message-ID: <00da01c45bcb$b1381d70$0200000a@SAGEAME> From: "antenneX" To: "Giorgos Keramidas" References: <00ce01c45ba0$343ffc00$0200000a@SAGEAME> <20040626184008.GB1016@gothmog.gr> Date: Sat, 26 Jun 2004 17:19:39 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 cc: freebsd-questions@freebsd.org Subject: Re: A SED script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: antenneX List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jun 2004 22:19:54 -0000 ----- Original Message ----- From: "Giorgos Keramidas" To: "antenneX" Cc: Sent: Saturday, June 26, 2004 1:40 PM Subject: Re: A SED script > On 2004-06-26 12:08, antenneX 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. > Indeed, this works fine. The old/new files are needed to set the varibles to hold the new number for the next time as this is run via cron. old = ATX060 new = ATX070 ....then, after the script changes the line in the perl script, it needs to pipe (echo/cat) in the new file contents to the old: cat newfile > oldfile ---> which is now ATX070 for oldfile ...then incremement the newfile to become "ATX080" and so on.... Now, got to figure out how to increment number up. It is an invoice prefix number that contains the month # and must modify the perl file that is part of a custom order set of scripts.....