[ale] Bash scripting and printf
ari
myo at thy.dyn.ml.org
Tue Sep 15 11:09:49 EDT 1998
Bob Kruger (bkruger at mindspring.com) said this stuff:
> At 12:38 PM 9/14/98 -0400, you wrote:
>
> >are you familiar with C?
> >its format is similar to C's printf.
>
> Not really. However, I have worked with Perl a good bit.
that makes things more difficult for you, considering what i'm about to tell
you.
<snip>
>
> Thanks. I got this to work just fine, but still can not find a way to do
> the following:
>
> Right justify.
can't do it.
it's a shell; it's not made to be a complete programming language.
command-line shells don't "know" where the boundaries of your screen are, and
therefore can't implement them into the scripting language. the most common
width is 80, but you can never be sure (though my graphical terms are kept at
80x25, my text terminals are anywhere from 100x40 to 160x60).
you'll need to write a program to right-justify the text input to it. then
call that program with your sh script, and feed it the text you want it to
right-justify.
> Buffer with blank spaces a variable being printed.
i'm not positive what you mean by this.
something like
printf "high-%d %s ... and stuff.\n" 5 "joe"
(spaces around the variable)
or
printf "high-%d\t%s\t... and stuff.\n" 5 "joe"
(tabs around the variable)
or
printf "high-%d %23s.\n" 5 "joe"
(allocate 23 spaces for the variable)
or what?
ari
More information about the Ale
mailing list