Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3F155A90.2173F884@dessent.net> Date: Wed, 16 Jul 2003 07:00:48 -0700 From: Brian Dessent Organization: My own little world... X-Accept-Language: en,en-US MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Cygwin's vanilla sed : capabilities and limitations References: <000701c34b9a$1c7e6c80$6fc82486 AT medschool DOT dundee DOT ac DOT uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit fergus AT bonhard DOT uklinux DOT net wrote: > Q1. Querying info sed reveals the expression matcher to be "greedy", > matching the longest possible string. Is there a way to make it match the > shortest possible, so that echo aaabbbccc | sed 's/^.*b//' (altered but > similar) grabs aaab not aaabbb? If you have perl available (or just a tool that uses perl-compatible regexps, i.e. grep -P) you can add the '?' character after any qualifier to get the non-greedy version, i.e. '*?' is the non-greedy '*', '??' is the non-greedy '?', etc. But this is a feature of pcre, which I don't believe applies to sed in any shape or form. However, most sed scripts are pretty easy to do in perl with little modification, so if you require this function that's what I'd do. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/