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

Re: Truncate without padding



    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> 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.

    Sorry, I didn't mention that it has to be done in one step
(namely in the print command) and the "string" to be printed is $*.

    I think I could save "$*" in a parameter (it won't be splitted
nor any other thing except printed) and apply your solution :)
Anyway, is there a way of doing all in one step, with the
restrictions I mention above?

> 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.

    It's OK to use '\0' if I apply this solution, althoug it is not
needed because ALL pad characters will be " " and ALL pad characters
will be added by the pad flags. The string won't have trailing or
leading spaces (well, it is not supossed to...) Thanks :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...



Messages sorted by: Reverse Date, Date, Thread, Author