Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
convert sed to zsh
- X-seq: zsh-users 20995
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: convert sed to zsh
- Date: Thu, 26 Nov 2015 09:49:25 -0800
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I'm trying to convert a 'sed' filter to native zsh. Here's the sed:
bar=$( echo $foo |
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" )
Here's my candidate zsh:
bar=$foo//$'\x1B'\[([0-9](#c0,2)(;[0-9](#c0,2))#)#[mGK]/}
... so far it's working, but I'm nervous about it. In another context
it seems I have to backslash the semi-colon, but here it seems ok either
way, but of course it should be one or the other. The 'sed' is of course
the kosher way (I believe) of removing color codes and various other
escapes like "\e[K" that seem to hang around colorized output of 'grep'
and so on. With several different forms of color codes, I want to be
sure I get this right. Unless of course zsh already has a stock way of
stripping escape sequences, which it very well might.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author