- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk remove lines format to columns
Operating System - HP-UX
1748123
Members
3267
Online
108758
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
Go to solution
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
тАО01-13-2009 02:24 PM
тАО01-13-2009 02:24 PM
I am trying to write a ksh script that pulls data to a file, have it working no problem.
format of file.
13-JAN-09-22:17:00
12-JAN-09-07:13:07
NULL
NULL
13-JAN-09-21:08:04
Some times the NULL values will also be dates.
So I want to take this and join lines and format to columns.
Here is what I have working:
cat test.1| tr '\n' '\t'|awk '{print $1, $2, $3, $4, $5}'>>monitor.log
what I would like to do is have each variable line up at certain column.
Because right now the file looks fine:
13-JAN-09-22:16:38 12-JAN-09-07:12:57 NULL NULL 13-JAN-09-21:08:04
13-JAN-09-22:17:00 12-JAN-09-07:13:07 NULL NULL 13-JAN-09-21:08:04
But if I get an entry in $3 $4, nothing will line up anymore.
So how do I format $1 to start at 1, $2 start at 15 $3 start at the next 15... on so on.
format of file.
13-JAN-09-22:17:00
12-JAN-09-07:13:07
NULL
NULL
13-JAN-09-21:08:04
Some times the NULL values will also be dates.
So I want to take this and join lines and format to columns.
Here is what I have working:
cat test.1| tr '\n' '\t'|awk '{print $1, $2, $3, $4, $5}'>>monitor.log
what I would like to do is have each variable line up at certain column.
Because right now the file looks fine:
13-JAN-09-22:16:38 12-JAN-09-07:12:57 NULL NULL 13-JAN-09-21:08:04
13-JAN-09-22:17:00 12-JAN-09-07:13:07 NULL NULL 13-JAN-09-21:08:04
But if I get an entry in $3 $4, nothing will line up anymore.
So how do I format $1 to start at 1, $2 start at 15 $3 start at the next 15... on so on.
Solved! Go to Solution.
- Tags:
- awk
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2009 02:37 PM
тАО01-13-2009 02:37 PM
Solution
Hi:
> So how do I format $1 to start at 1, $2 start at 15 $3 start at the next 15... on so on.
You use formatted print statements:
# cat test.1|tr '\n' '\t'|awk '{printf "%-15s %-15s %-15s %-15s %-15s\n",$1,$2,$3,$4,$5}'
This lef-justifies fields in units of 15-characters. See the manpages for 'printf'.
Regards!
...JRF...
> So how do I format $1 to start at 1, $2 start at 15 $3 start at the next 15... on so on.
You use formatted print statements:
# cat test.1|tr '\n' '\t'|awk '{printf "%-15s %-15s %-15s %-15s %-15s\n",$1,$2,$3,$4,$5}'
This lef-justifies fields in units of 15-characters. See the manpages for 'printf'.
Regards!
...JRF...
- Tags:
- printf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2009 02:41 PM
тАО01-13-2009 02:41 PM
Re: awk remove lines format to columns
Works PERFECT!
I have been fiddling with printf and nothing but errors.
Put a question in and I got a reply with 10 minutes!
I have been fiddling with printf and nothing but errors.
Put a question in and I got a reply with 10 minutes!
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