- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk help
Operating System - HP-UX
1752328
Members
5993
Online
108786
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО11-09-2010 11:05 AM
тАО11-09-2010 11:05 AM
awk help
Hi ALL,
I am doing an awk on a file and getting the output as below, is there a way I can have spacing between $2 and $4 so that $4 is lined up symmetrically unlike what I am getting below?
awk -F: '{print $2"\t\t\t"$4}' filename
xxxxxxxxxxxxx 8581
xxx 8585
xxxxxx 8590
xxxx 8595
xxxxxxx 9400
xx 9510
xxxxxxxxxxxxxxx 9520
Thanks,
Allan.
I am doing an awk on a file and getting the output as below, is there a way I can have spacing between $2 and $4 so that $4 is lined up symmetrically unlike what I am getting below?
awk -F: '{print $2"\t\t\t"$4}' filename
xxxxxxxxxxxxx 8581
xxx 8585
xxxxxx 8590
xxxx 8595
xxxxxxx 9400
xx 9510
xxxxxxxxxxxxxxx 9520
Thanks,
Allan.
- Tags:
- awk
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 11:16 AM
тАО11-09-2010 11:16 AM
Re: awk help
>> symmetrically
Not sure anyone understand clearly what that means.
Terms folks tend to understand are columns and field and left of right aligned.
Anyway...
Use a PRINTF instead of PRINT
Use '%-?ns' for a left-aligned ?-columns wide string field.
For the second column ($4) you may want a %0?d formatting if you want to play with leading zeroes.
Read any C, AWK, PERL or SHell book or man-page for all the details.
Hein
For example, using your output as input:
$ awk '{printf ("%-20s%6s\n",$1,$2)}' x.x
Not sure anyone understand clearly what that means.
Terms folks tend to understand are columns and field and left of right aligned.
Anyway...
Use a PRINTF instead of PRINT
Use '%-?ns' for a left-aligned ?-columns wide string field.
For the second column ($4) you may want a %0?d formatting if you want to play with leading zeroes.
Read any C, AWK, PERL or SHell book or man-page for all the details.
Hein
For example, using your output as input:
$ awk '{printf ("%-20s%6s\n",$1,$2)}' x.x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 11:30 AM
тАО11-09-2010 11:30 AM
Re: awk help
yep, use printf
Support Fatherhood - Stop Family Law
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 03:29 PM
тАО11-09-2010 03:29 PM
Re: awk help
The original awk statement worked for me once I redirected the output to xls file.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP