Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Truncate without padding



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