From owner-freebsd-questions@FreeBSD.ORG Thu Dec 22 18:33:30 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 DACC416A41F for ; Thu, 22 Dec 2005 18:33:30 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C59B43D75 for ; Thu, 22 Dec 2005 18:33:29 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id jBMIWo8f012427; Thu, 22 Dec 2005 12:32:50 -0600 (CST) (envelope-from dan) Date: Thu, 22 Dec 2005 12:32:50 -0600 From: Dan Nelson To: Mikhail Teterin Message-ID: <20051222183250.GB39217@dan.emsphone.com> References: <200512211704.49530.mi+mx@aldan.algebra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200512211704.49530.mi+mx@aldan.algebra.com> X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.11 Cc: freebsd-questions@freebsd.org Subject: Re: what's an equivalent for the following Perl one-liner? 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: Thu, 22 Dec 2005 18:33:31 -0000 In the last episode (Dec 21), Mikhail Teterin said: > I'd like a sed string, that will remove both the carriage returns and > the blanks at eol in one go. Perl appears to recognize the \r > character and DTRT: > > perl -p -e 's,[ \r]+$,,' < in > out > > What's the sed's equivalent? Thanks! sed -E 's,[ ^M]*$,,' < in > out Note the ^M is a single control-character (entered via Ctrl-V Ctrl-M at a shell prompt for example). sed does not parse backslash-escapes except for \n which represents a newline. -- Dan Nelson dnelson@allantgroup.com