Re: [Linuxcommand-discuss] shell printf function
Brought to you by:
bshotts
From: Bram M. <bra...@li...> - 2003-03-28 19:10:00
|
On Sun, 2003-02-16 at 03:30, William Shotts wrote: > Bram Mertens wrote: [snip] > > ---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--- [snip] > 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" I can't seem to get this working, I've tried several variations of the following but A always get the same error: m8ram@linux:~> sig-general # SuSE 8.1 Pro kernel 2.4.19-4GB i686 128MB RAM # # 7:59pm up 11 days, 1:21, 6 users, load average: 2.18, 2.13, 2.10 # /home/m8ram/bin/sig-general: line 9: syntax error near unexpected token `"# %-65s #",' /home/m8ram/bin/sig-general: line 9: `printf("# %-65s #", curent_uptime)' I've tried to specify the variable as $current_uptime, $(surrent_uptime), ($current_uptime),... I've tried %c and %s, single quotes, double quotes... What is the right format? TIA -- # Mertens Bram "M8ram" <bra...@li...> Linux User #249103 # # SuSE 8.1 Pro kernel 2.4.19-4GB i686 128MB RAM # # 8:01pm up 11 days, 1:23, 6 users, load average: 2.59, 2.22, 2.13 # |