Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Truncate without padding
- X-seq: zsh-users 9597
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Truncate without padding
- Date: Mon, 31 Oct 2005 15:35:12 +0000
- In-reply-to: <20051031112743.GA1048@DervishD>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20051031112743.GA1048@DervishD>
On Oct 31, 12:27pm, DervishD wrote:
}
} I would like to print a string truncated *but* without padding
Just truncate it first with padding, and then strip the padding.
${${(pl:WIDTH::::\0:)string}#*$'\0'}
${${(pr:WIDTH::::\0:)string}%$'\0'*}
You can pick some other character than NUL if you know that character
doesn't appear in the string, in which case you don't need the (p) flag.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author