- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 02:34 AM
тАО03-07-2005 02:34 AM
I want to know what are the standart ways to format the output of the script?
For explamle I need the following output:
Mount Size Comments
/opt 345 Testing bla
/software/omni 8003 bla bla bla
If I use printf(1) to format the output, it's only padding from the left and I need padding from the right, is there any way to tell printf to pad from the right?
(I'm using onl bash, no perl, php etc ...)
Solved! Go to Solution.
- Tags:
- printf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 02:36 AM
тАО03-07-2005 02:36 AM
Re: Script question
adjust -r, else awk printf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 02:40 AM
тАО03-07-2005 02:40 AM
SolutionBut the format argument of bash's printf allows for a '-' sign to indicate right alignment and a figure to indicate field width.
Example
bash$ printf "%14d\n" 12
............12
AND
bash$ printf "%-14d" 12
12............
I've replaced the spaces with '.'s to show you what is happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 02:41 AM
тАО03-07-2005 02:41 AM
Re: Script question
printf "%20s%-20s%-20.20s\n" AA BB CC
The "-" pads on the right, -20.20 pads on the right but also limits the total width of the field to 20 so that it can both pad and truncate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 02:43 AM
тАО03-07-2005 02:43 AM
Re: Script question
typeset -L var1 # var1 is Left-justified, remove leading spaces
typeset -R var2 # var2 is Right-justified, remove trailing spaces
typeset -L8 var3 # var3 is Left-justified, padded to 8 chars total, remove leading spaces
typeset -R9 var4 # var4 is Right-justified, padded to 9 chars total, remove trailing spaces
- Tags:
- typeset
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 04:05 AM
тАО03-07-2005 04:05 AM