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 To: Subject: RE: OT: Using sed - guru help wanted. Message-ID: From: erik DOT cumps AT icos DOT be Date: Tue, 21 Oct 2003 11:36:01 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Hi guys, sorry if this thread was dead but couldn't resist. Besides, it makes the start of my workday just that more bearable... :) (regular expressions for fun and profit eh) Simply sed: sed 's#^ *\(.*[^ ]\) */ *\(.*[^ ]\) *$#.\1.\2.#' Simply perl: perl -pe 's/^\s*(.*\S)\s*\/\s*(.*\S)\s*$/.$1.$2./' Both will split at the slash and strip leading/trailing spaces from the parts, even if a part contains just a single non-whitespace character, even if there is no whitespace to remove. Simple explanation: at start of string; zero or more spaces; string of zero or more characters; non-space character; zero or more spaces; slash; zero or more spaces; string of zero or more characters; non-space character; zero or more spaces; at end of string. HTH, Erik As it seems my query wasn't that well formed... i.e. remove any leading and/or trailing spaces on the parts. Parts separated by the slash. This seems to do exactly what I'm after; $ echo 'a b/c d e ' | \ sed -re 's- *(.*[^ ]) */ *(.*[^ ]) *$-.\1.\2.-' Thanks for the input, Brian and Igor. -- 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/ -- 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/