From owner-freebsd-questions@FreeBSD.ORG Sat Jun 26 19:38:12 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 74D4C16A4CE for ; Sat, 26 Jun 2004 19:38:12 +0000 (GMT) Received: from wonkity.com (wonkity.com [65.173.111.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21BFA43D1D for ; Sat, 26 Jun 2004 19:38:12 +0000 (GMT) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.12.11/8.12.11) with ESMTP id i5QJc0hm089638; Sat, 26 Jun 2004 13:38:00 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.12.11/8.12.11/Submit) with ESMTP id i5QJc0Hu089635; Sat, 26 Jun 2004 13:38:00 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Sat, 26 Jun 2004 13:38:00 -0600 (MDT) From: Warren Block To: antenneX In-Reply-To: <00ce01c45ba0$343ffc00$0200000a@SAGEAME> Message-ID: <20040626133350.G89583@wonkity.com> References: <00ce01c45ba0$343ffc00$0200000a@SAGEAME> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.3.8 (wonkity.com [127.0.0.1]); Sat, 26 Jun 2004 13:38:00 -0600 (MDT) 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: Sat, 26 Jun 2004 19:38:12 -0000 On Sat, 26 Jun 2004, antenneX wrote: > Running FBSD-4.10 > > Below is a portion of a script that uses sed(1) to change a portion of a > line in a file. It works fone for that one. > > However, 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 > > ....and, again the line in the file: > $OrderNumPrefix = "ATX060"; <---line in the file to change > > What do I need to change to make it work....??? You don't show what changes you have made to the program. A first guess is that you aren't escaping quotes. If you insert an "echo" command before the sed command, you'll be able to see what is actually going on. You may get away with just changing the sed pattern delimiter, say to something like a "%" sign. -Warren Block * Rapid City, South Dakota USA