From owner-freebsd-questions@FreeBSD.ORG Sat Apr 7 18:00:23 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1F8E916A403 for ; Sat, 7 Apr 2007 18:00:23 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (wonkity.com [67.158.26.137]) by mx1.freebsd.org (Postfix) with ESMTP id E29F513C4BF for ; Sat, 7 Apr 2007 18:00:20 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.13.8/8.13.8) with ESMTP id l37I0KwR069287; Sat, 7 Apr 2007 12:00:20 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.13.8/8.13.8/Submit) with ESMTP id l37I0HWk069284; Sat, 7 Apr 2007 12:00:17 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Sat, 7 Apr 2007 12:00:17 -0600 (MDT) From: Warren Block To: Olivier Regnier In-Reply-To: <4617B954.7010507@steelbox.org> Message-ID: <20070407114330.D68971@wonkity.com> References: <4617B954.7010507@steelbox.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (wonkity.com [127.0.0.1]); Sat, 07 Apr 2007 12:00:20 -0600 (MDT) Cc: freebsd-questions@freebsd.org Subject: Re: script perl with sed command X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2007 18:00:23 -0000 On Sat, 7 Apr 2007, Olivier Regnier wrote: > I have a problem with my perl script with the command sed. Here is a example > of my code: > > # Selecting the fast server > print "Using the server called $server"; > system(`/usr/bin/sed 's|\*default host=\(.*\)|\*default host=${server}|' > $standard_supfile > $standard_supfile.copy`); > system('/bin/mv $standard_supfile.copy $standard_supfile'); > > But in console i have this message: > sed: 1: "s|*default host=(.*)|*d ...": unescaped newline inside subsitute > pattern Most likely there is a newline at the end of $server because it was output from backticks. To fix that, you'd use chomp: chomp(my $server = `fastest_csvsup -Q -c us`); Just a general note: Perl's s/ command does more than sed's, with less hassle, and you wouldn't have to mess with shell escapes. -Warren Block * Rapid City, South Dakota USA