From owner-freebsd-questions@FreeBSD.ORG Sat Apr 7 20:06:48 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 E31DC16A400 for ; Sat, 7 Apr 2007 20:06:48 +0000 (UTC) (envelope-from oregnier@steelbox.org) Received: from 42.mail-out.ovh.net (42.mail-out.ovh.net [213.251.189.42]) by mx1.freebsd.org (Postfix) with SMTP id 45CF913C45D for ; Sat, 7 Apr 2007 20:06:48 +0000 (UTC) (envelope-from oregnier@steelbox.org) Received: (qmail 11073 invoked by uid 503); 7 Apr 2007 20:07:01 -0000 Received: from gw2.ovh.net (HELO mail186.ha.ovh.net) (213.251.189.202) by 42.mail-out.ovh.net with SMTP; 7 Apr 2007 20:07:01 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 7 Apr 2007 20:06:39 -0000 Received: from mac76-2-82-241-6-173.fbx.proxad.net (HELO ?192.168.1.2?) (postmaster@steelbox.org@82.241.6.173) by ns0.ovh.net with SMTP; 7 Apr 2007 20:06:39 -0000 Message-ID: <4617FA0D.2040703@steelbox.org> Date: Sat, 07 Apr 2007 22:07:41 +0200 From: Olivier Regnier User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Warren Block References: <4617B954.7010507@steelbox.org> <20070407114330.D68971@wonkity.com> In-Reply-To: <20070407114330.D68971@wonkity.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Remote: 82.241.6.173 (mac76-2-82-241-6-173.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.5/N 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 20:06:49 -0000 Warren Block a écrit : > 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 > _______________________________________________ > 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" Ok thank you for your answer. The script work well.