Re: [Linuxcommand-discuss] shell printf function
Brought to you by:
bshotts
From: William S. <bs...@pa...> - 2003-02-16 02:31:14
|
Bram Mertens wrote: > Hi, > > The signature at the end of this message is generated by two little > shell-scripts I wrote: > ---sig-linux--- > #!/bin/bash > > echo '<pre>-- ' > echo '# Mertens Bram "M8ram" <bra...@li...> Linux User > #249103 #' > /home/m8ram/bin/sig-general > ---end--- > ---sig-general--- > #!/bin/bash > current_uptime=$(uptime) > current_kernel=$(uname -r) > current_machine=$(uname -m) > current_release="SuSE 8.1 Pro" > > echo -n '# '; echo -n $current_release; echo -n ' kernel '; echo -n > $current_kernel; echo -n ' '; echo -n $current_machine; echo ' 128MB RAM > #' > echo -n '# '; echo -n $current_uptime; echo ' #' > echo '</pre>' > ---end--- > > Unfortunately it still doesn't look very pretty, what I would like is > something like: > ---new-sig--- > # Mertens Bram "M8ram" <bra...@li...> Linux User #249103 # > # SuSE 8.1 Pro kernel 2.4.19-4GB i686 128MB RAM # > # 1:16am up 12:19, 1 user, load average: 0.06, 0.04, 0.06 # > ---end--- > > Is there a shell-function that allows the output to be of certain length > like printf in C and Perl (IIRC)? > I want all lines to be 78 chars wide, regardless of the kernel-version > or the uptime. > > Is this possible with a shell-script? Or should I write a Perl-script? > > TIA bash contains a printf command that is mostly like the C/perl/etc function. Try "help printf" at the bash prompt. Failing that, many distributions have a printf program that can be called from scripts. Try "man printf" -- ||||| William Shotts, Jr. (bshotts AT panix DOT com) ||||| Be a Linux Commander! Follow me to http://linuxcommand.org |