- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: rows to column
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
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
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-21-2014 02:41 PM
03-21-2014 02:41 PM
rows to column
I have a file with entries as below:
var1:mango
quantity:w1245
season: alphanso
var1:apple
quantity:c324
season:winter
var1:cherry
quantity:b4326
season:autumn
....
......
I want the file o/p like
var1 quantity season
mango w1245 alphanso
apple c324 winter
cherry b4326 autumn
mango b67588 spring
....
...
Many thanks ,
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2014 03:33 PM
03-21-2014 03:33 PM
Re: rows to column
Assuming you have no spaces in the file and the three lines are always in that order:
awk -F: '
{
var1 = $2
getline
quantity = $2
getline
season = $2
print var1, quantity, season
}' input-file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2014 05:54 AM
03-26-2014 05:54 AM
Re: rows to column
Hi Dennis ,
thank you for the reply.
I used awk -F':' and extracted the second filed and then did a #paste -d"," - - - < details.txt , to generate the required csv.
Thanks once again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2014 08:46 PM
03-26-2014 08:46 PM
Re: rows to column
>I used awk -F':' and extracted the second field and then did a paste
You didn't need to use both awk and paste, you can do it all in awk by changing OFS to comma:
awk -F: -v OFS="," ' ....