Re: Printf in sh oder zsh

From: Oliver Fromme <olli(at)secnetix.de>
Date: Mon, 3 Jun 2002 11:22:25 +0200 (CEST)

Matthias Teege <matthias(at)mteege.de> wrote:
> ich möchte mit wenig Aufwand die Länge eines Strings überwachen und
> ihn ggf. kürzen. Printf scheint aber nicht auszureichen.
>
> Unter sh gibt ein printf '%5s' hello_world den vollständigen String
> aus

$ printf '%5.5s\n' hello_world
hello

Bei Strings (%s) gibt die »precision« (der Wert nach dem
Punkt) die Maximallänge an. Siehe auch die printf(1)
manpage.

Gruß
   Olli

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
"All that we see or seem is just a dream within a dream" (E. A. Poe)
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Mon 03 Jun 2002 - 11:22:28 CEST

search this site