Re: issues using printf



On 2010-01-14, peter sands <peter_sands@xxxxxxxxxxxxx> wrote:
Hello,
I am having problems using printf in presenting my data, in
that it is all over the place.
I am using the printf command:

printf "%-10s %10s %10 %40s\n" $cont $lock $set $time_cont

You probably want "-" on all of these. The third seems to have no
format specifier; you probably want an s. Finally, be sure to quote
the arguments.

printf "%8s" $time_cont

ought to give you
"Wed Apr 1 09:35:09BST 2009 "

(with no newline).

The reason is that, if you provide extra arguments, printf cycles through
its argument string for them, and $time_cont appears to expand to multiple
words.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@xxxxxxxxx
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
.



Relevant Pages

  • Re: PRINTF.C?
    ... printf() is a function so this ... [debugger asking where to find printf.c for debugging inside the ... and every Platform SDK to date..maybe certain 'cut down' versions of VC ...
    (microsoft.public.vc.language)
  • Re: PRINTF.C?
    ... printf() is a function so this ... rather a function call or function invocation. ... [debugger asking where to find printf.c for debugging inside the function] ...
    (microsoft.public.vc.language)
  • Re: Adding a FormFeed to an LPR printcap file?
    ... want to use the printf command with a hex value, ... >> My guess is I need to add it to my printer filter, ...
    (freebsd-questions)
  • Re: issues using printf
    ... I am using the printf command: ... Glenn Jackman ... Write a wise saying and your name will live forever. ...
    (comp.unix.shell)
  • Re: First address of a bidimensional array
    ... Why the first address of this array is only: ... See the diagram at: there ... are multiple "first address"-es, differing in type, and hence in ... Based on what you get if you do printf() those, ...
    (comp.lang.c)