- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Help on perl join
Operating System - Linux
1753720
Members
5013
Online
108799
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
тАО10-12-2007 06:53 AM
тАО10-12-2007 06:53 AM
All,
I have text file as follow. I need help in joining three(3) lines.
9/1/2007 0:00
4.00
3.38
9/2/2007 0:00
3.86
2.95
9/3/2007 0:00
3.90
3.18
Following are the result I'm looking for.
9/1/2007 0:00 4.00 3.38
9/2/2007 0:00 3.86 2.95
9/3/2007 0:00 3.90 3.18
Thanks, in advance.
JC
I have text file as follow. I need help in joining three(3) lines.
9/1/2007 0:00
4.00
3.38
9/2/2007 0:00
3.86
2.95
9/3/2007 0:00
3.90
3.18
Following are the result I'm looking for.
9/1/2007 0:00 4.00 3.38
9/2/2007 0:00 3.86 2.95
9/3/2007 0:00 3.90 3.18
Thanks, in advance.
JC
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2007 08:07 AM
тАО10-12-2007 08:07 AM
Solution
Hi JC:
# cat ./myjoin
#!/usr/bin/perl
use strict;
use warnings;
my $i = 0;
my @line;
while (<>) {
chomp;
$i++;
if ( $i <= 3 ) {
push @line, $_;
}
else {
$i = 1;
print "@line\n";
@line = ();
push @line, $_;
}
}
print "@line\n" if @line;
1;
...run as:
./myjoin file
Regards!
...JRF...
# cat ./myjoin
#!/usr/bin/perl
use strict;
use warnings;
my $i = 0;
my @line;
while (<>) {
chomp;
$i++;
if ( $i <= 3 ) {
push @line, $_;
}
else {
$i = 1;
print "@line\n";
@line = ();
push @line, $_;
}
}
print "@line\n" if @line;
1;
...run as:
./myjoin file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2007 10:54 AM
тАО10-12-2007 10:54 AM
Re: Help on perl join
James,
I appreciate your reply. Thank, for the script.
Thread Close
JC
I appreciate your reply. Thank, for the script.
Thread Close
JC
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