From owner-freebsd-questions@FreeBSD.ORG Sun Jun 27 03:35:52 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 09CD416A4D6 for ; Sun, 27 Jun 2004 03:35:52 +0000 (GMT) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id 55B8943D1F for ; Sun, 27 Jun 2004 03:35:51 +0000 (GMT) (envelope-from malcolm.kay@internode.on.net) Received: from beta.home (ppp34-240.lns1.adl1.internode.on.net [150.101.34.240])i5R3ZLHY026426; Sun, 27 Jun 2004 13:05:22 +0930 (CST) From: Malcolm Kay Organization: at home To: antenneX , "Giorgos Keramidas" Date: Sun, 27 Jun 2004 13:05:21 +0930 User-Agent: KMail/1.5.4 References: <00ce01c45ba0$343ffc00$0200000a@SAGEAME> <20040626184008.GB1016@gothmog.gr> <00da01c45bcb$b1381d70$0200000a@SAGEAME> In-Reply-To: <00da01c45bcb$b1381d70$0200000a@SAGEAME> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200406271305.21121.malcolm.kay@internode.on.net> cc: freebsd-questions@freebsd.org Subject: Re: A SED script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jun 2004 03:35:52 -0000 On Sunday 27 June 2004 07:49, antenneX wrote: > ----- 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` It would seem that the variables new and old will both be set to something containing 'new' (perhaps not in lower case). How does this relate to "ATX060" and "ATX070"? > > > 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. > You've still not shown us the relevant lines of /path/to/newfile or /path/to/oldfile > old = ATX060 > new = ATX070 What are these? The contents of /path/to/{new,old}file? If so sed will be looking to change the string "old = ATX060" to "new = ATX070". Or do the files simply consist of ATX060 and ATX070 ? If so then grep is not the right command to load the variables old and new. Try: new=`cat /path/to/newfile` old=`cat /path/to/oldfile` Malcolm > > ....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..... > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"