Browse
Hewlett Packard Enterprise Community
Sign In
Help
Community Home
>
Servers and Operating Systems
>
Operating Systems
>
Operating System - HP-UX
>
Re: printf
Options
Subscribe to RSS Feed
Mark Topic as New
Mark Topic as Read
Float this Topic for Current User
Bookmark
Subscribe
Printer Friendly Page
All community
This category
This board
Knowledge base
Users
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Search instead for
Did you mean:
printf
jmckinzie
Super Advisor
Mark as New
Bookmark
Subscribe
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
02-25-2009
10:00 AM
02-25-2009
10:00 AM
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
Tags
(1)
Tags:
printf
All forum topics
Previous Topic
Next Topic
3 REPLIES
3
James R. Ferguson
Acclaimed Contributor
Mark as New
Bookmark
Subscribe
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
02-25-2009
10:05 AM
02-25-2009
10:05 AM
Re: printf
Hi:
# WS=xyz
# PASS=abc
# printf "%-20s%s%-20s%s\n" $WD $PASS
xyz abc
Regards!
...JRF...
James R. Ferguson
Acclaimed Contributor
Mark as New
Bookmark
Subscribe
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
02-25-2009
10:09 AM
02-25-2009
10:09 AM
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...
Highlighted
James R. Ferguson
Acclaimed Contributor
Mark as New
Bookmark
Subscribe
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
02-25-2009
10:19 AM
02-25-2009
10:19 AM
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...