Date: Sat, 07 Apr 2007 22:07:41 +0200 From: Olivier Regnier <oregnier@steelbox.org> To: Warren Block <wblock@wonkity.com> Cc: freebsd-questions@freebsd.org Subject: Re: script perl with sed command Message-ID: <4617FA0D.2040703@steelbox.org> In-Reply-To: <20070407114330.D68971@wonkity.com> References: <4617B954.7010507@steelbox.org> <20070407114330.D68971@wonkity.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4617FA0D.2040703>
