Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Strip a Carriage-Return from a string/variable
- X-seq: zsh-users 14320
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Strip a Carriage-Return from a string/variable
- Date: Tue, 25 Aug 2009 17:12:46 +0100
- In-reply-to: <Xns9C72ADE69DF67zzappergmailcom@xxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns9C72ADE69DF67zzappergmailcom@xxxxxxxxxxxx>
zzapper wrote:
> Hi
> print ${somevar//[^[:alnum:]]/_} # replace all non-alphanumerics with _
>
> But how to delete just a trailing or not carriage return?
% foo=$'bar\r'
% print $foo | xxd
0000000: 6261 720d 0a bar..
% print ${foo%%$'\r'} | xxd
0000000: 6261 720a bar.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
'member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author