this will do it
print "${buf/?(*$'\n')@(part5:*([^\n]))*/\2}"
but the perl style of reading in a whole file before operating on it
will eventually run into resource limitations
-- Glenn Fowler -- AT&T Research, Florham Park NJ --
On Tue, 13 May 2008 13:18:40 +0200 William James wrote:
> Imagine I have a file like this:
> buf="$(cat <<EOF
> part1: a part
> part5: another part
> # comment
> part9: 9th part
> EOF
> )"
> How can I get the line containing 'part5' using ksh93 string
> operators, avoiding both 'while read...' and 'sed'? I tried
> ${buf##pattern}, ${buf#pattern}, ${buf%pattern}, ${buf%%pattern} but
> they all _remove_ the string pattern. I need a string operator which
> only leaves the string matching pattern and removes the rest.
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users