- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: file manipulation with scripts
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
Forums
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
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
08-06-2004 04:52 AM
08-06-2004 04:52 AM
I have a file that looks like this:
User: frencht
License: panth.5.0
License: panth_des.5.0
User: miedicr
License: panth_des.5.0
User: patriet
License: panth.5.0
License: panth_des.5.0
User: gormanl
License: panth.5.0
License: panth_des.5.0
User: bozzad
License: panth_des.5.0
It is a username followed by any number of license lines for licenses that are checked out. How can I change the format of this file so that it looks like this:
User: frencht panth.5.0 panth_des.5.0
User: miedicr panth_des.5.0
User: patriet panth.5.0 panth_des.5.0
User: gormanl panth.5.0 panth_des.5.0
User: bozzad panth_des.5.0
I am sure there is a relatively simple way, but I've been messing around with awk and sed and haven't quite got it. Please help!
Thanks,
Theresa
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 05:07 AM
08-06-2004 05:07 AM
SolutionThis should work:
awk -F: '/User/ {printf("\nUser:%s",$2);continue}
{printf("%s ",$2)}
END {print ""}' FILE | awk 'NR>1 {print}'
If empty string in the output is not a problem, remove second awk
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 05:24 AM
08-06-2004 05:24 AM
Re: file manipulation with scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 06:38 PM
08-06-2004 06:38 PM
Re: file manipulation with scripts
awk -F ":" '{ if ( $1 == "User" ) printf("\n%s",$2)
if ( $1 == "License" ) printf("%s",$2) } END { print ("\n") }' filename
frencht panth.5.0 panth_des.5.0
miedicr panth_des.5.0
patriet panth.5.0 panth_des.5.0
gormanl panth.5.0 panth_des.5.0
bozzad panth_des.5.0
- muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2004 05:00 AM
08-11-2004 05:00 AM