- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting help
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
тАО06-28-2005 10:39 AM
тАО06-28-2005 10:39 AM
I have a file of about 900 records which looks as follows:
1234
abc
def
9987
hjs
uds
7657
hds
jdk
....
....
I need to write a script that converts the file to this pattern:
1234 abc def
9987 hjs uds
7657 hds jdk
..............
..............
Can anyone please help me.
Thanks,
Anand
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 10:49 AM
тАО06-28-2005 10:49 AM
SolutionIf so then create a file called "useme.awk" that looks like this:
BEGIN{darec=0;}
darec==0 {keep1=$1; darec++;next;}
darec==1 {keep2=$1; darec++;next;}
{print keep1, keep2, $1;darec=0;}
then run it like this:
awk -f useme.awk < inputfile > outputfile
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 07:04 PM
тАО06-28-2005 07:04 PM
Re: scripting help
# awk '{ if ( NR %3 != 0 ) { printf $0" ";} else if ( NR %3 == 0 ) { print $0}}' testfile
1234 abc def
9987 hjs uds
7657 hds jdk
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2005 02:13 AM
тАО06-29-2005 02:13 AM
Re: scripting help
pr -3 -a -s\ -t yourfile
(Their are 2 spaces after \)
HTH
-- Rod Hills
- Tags:
- pr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 07:01 AM
тАО07-01-2005 07:01 AM
Re: scripting help
I have one more task to be done.
Can you please tell me how do i accomplish the reverse of it. That is if the file is:
1234 abc def
9987 hjs uds
7657 hds jdk
I want it to be of the form
1234
abc
def
9987
hjs
uds
7657
hds
jdk
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 07:12 AM
тАО07-01-2005 07:12 AM
Re: scripting help
- Tags:
- tr