1753973 Members
7803 Online
108811 Solutions
New Discussion юеВ

Re: printf

 
jmckinzie
Super Advisor

printf

I am trying to use printf to have output printed as below:

Variable 20 spaces Variable2

How do i do this?

printf "%-20s%s\n" $WD "%-20s%s\n" $PASS
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: printf

Hi:

# WS=xyz
# PASS=abc
# printf "%-20s%s%-20s%s\n" $WD $PASS
xyz abc

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: printf

Hi (again):

Ooops. Disregard the first post, please. You want 20-blanks between, so:

# printf "%-20s%20s%-20s%s\n" $WD "" $PASS

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: printf

Hi:

Well, I suppose "variable 20 spaces variable2" is probably without regard to the size of either variable despite your code snippet :-)

Hence:

# printf "%s%20s%s%s\n" $WD "" $PASS

Regards!

...JRF...