help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to extract matching suffix pattern in bash?


From: Dan Douglas
Subject: Re: [Help-bash] How to extract matching suffix pattern in bash?
Date: Wed, 13 Mar 2013 18:05:28 -0500
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

On Wednesday, March 13, 2013 05:21:56 PM Peng Yu wrote:
> Hi,
> 
> ${parameter%word} remove matching suffix pattern. I need something
> extract only the matching suffix which is to be not available
> according to bash manual. Do I miss anything?
> 
Combining them is the only way.

 ~ $ ( getSuffix(){ echo "${1#"${1%%$2}"}"; }; getSuffix 'aaabbb' 'b?[^a]' )
bbb

OFC there are other Bashism methods. This is about the best with a PE.
-- 
Dan Douglas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]