Re: [Linuxcommand-discuss] shell printf function
Brought to you by:
bshotts
From: Bram M. <bra...@li...> - 2003-03-30 18:39:02
|
On Fri, 2003-03-28 at 21:05, William Shotts wrote: > In bash, the correct format would be: > > printf "# %-65s #\n" "$current_uptime" > > Don't use the parens. Also, you need to quote the argument since it > contains embedded spaces. Lastly, you should include the "\n" in the > format string since there is no carriage return if you don't explicitly > specify it. Thanks! Here's the script with some more changes: #!/bin/bash current_uptime=$(uptime) current_kernel=$(uname -r) current_machine=$(uname -m) current_release="SuSE 8.1 Pro" mem="128MB" NAME="Mertens Bram \"M8ram\"" EMAIL=$1 LINUXID="Linux User #249103" printf "<pre>-- \n" printf "# %-22s %-29s %22s #\n" "$NAME" "$EMAIL" "$LINUXID" printf "# %-16s kernel %-15s %-6s %18s RAM #\n" "$current_release" "$current_kernel" "$current_machine" "$mem" printf "#%70s #\n" "$current_uptime" printf "</pre>\n" I have two other shell scripts that call this script to provide the correct e-mail address, they only contain a single line like: sig-general "<bra...@li...>" Where sig-general is the name of the above script. The reason I need this is because Evolution (my MUA) can call scripts to generate sigs but it can't pass arguments to those scripts (yet). You can see the result below, thanks again for the help! Regards -- # Mertens Bram "M8ram" <bra...@li...> Linux User #249103 # # SuSE 8.1 Pro kernel 2.4.19-4GB i686 128MB RAM # # 10:53am up 11 days, 16:15, 6 users, load average: 2.19, 2.10, 2.05 # |