- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Sorting data based on criteria in Perl
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
02-20-2006 02:26 PM
02-20-2006 02:26 PM
batchname|BNO123|BDA2006-02-19|
REC|DNO11|PNO1111|UPR0999
REC|DNO11|PNO1114|UPR0999
REC|DNO11|PNO1116|UPR0999
batchname2|BNO124|BDA2006-02-19|
REC|DNO11|PNO1112|UPR0999
REC|DNO11|PNO1111|UPR0999
REC|DNO10|PNO1111|UPR0999
I need to be able to sort by both DNO and PNO as they aren't unique. A sort where DNO=11 and PNO=1111 should yield this results:
batchname|BNO123|BDA2006-02-19|
REC|DNO11|PNO1111|UPR0999
batchname2|BNO124|BDA2006-02-19|
REC|DNO11|PNO1111|UPR0999
I'll be passing the search parameters in through a shell script but I'm a perl newbie and am having difficulty trying to use hashes to parse the data. Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:31 PM
02-20-2006 02:31 PM
Re: Sorting data based on criteria in Perl
# grep -E '^batchname|DNO11\|PNO1111' filename
will give results.
Change DN011\|PNO1111 based on requirement.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:33 PM
02-20-2006 02:33 PM
Re: Sorting data based on criteria in Perl
perl -ne 'print if /^batchname|DNO11\|PNO1111/' filename
change DN and PNO part based on your requirement.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:40 PM
02-20-2006 02:40 PM
Re: Sorting data based on criteria in Perl
- Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:44 PM
02-20-2006 02:44 PM
Re: Sorting data based on criteria in Perl
perl -ne 'print if /BNO[0-9]*|DNO11\|PNO1111/' filename
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:52 PM
02-20-2006 02:52 PM
Re: Sorting data based on criteria in Perl
-Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 03:04 PM
02-20-2006 03:04 PM
Re: Sorting data based on criteria in Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 07:30 PM
02-20-2006 07:30 PM
Re: Sorting data based on criteria in Perl
050269ýBNO426823ýBDA2006-02-19ýBTI080303ýEFD2006-02-18ýEFT00:01ýSRB0ýBTYOýRNO14ýSNO100ý
/375? what it is?
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 01:27 AM
02-21-2006 01:27 AM
Re: Sorting data based on criteria in Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 01:30 AM
02-21-2006 01:30 AM
Re: Sorting data based on criteria in Perl
-Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:33 AM
02-21-2006 02:33 AM
Solution$dno="DNO".$ENV{DNO}; $pno=PNO.$ENV{PNO};
while(<>) {
chomp;
@a=split("\375",$_);
if (substr($a[1],0,3) eq "BNO") {
$hdr=$_;
} else {
if ($a[1] eq $dno and $a[2] eq $pno) {
print $hdr,"\n";
print $_,"\n";
}
}
}
Then run with-
perl thisscript yourinputfile >resultfile
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:59 AM
02-21-2006 02:59 AM
Re: Sorting data based on criteria in Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 03:01 AM
02-21-2006 03:01 AM
Re: Sorting data based on criteria in Perl
$dno="DNO".$ENV{DNO}; $pno=PNO.$ENV{PNO};
while(<>) {
chomp;
@a=split("\375",$_);
if (substr($a[1],0,3) eq "BNO") {
$hdr=$_;
} else {
if ($a[1] eq $dno and $a[2] eq $pno) {
print $hdr,"\n";
print $_,"\n";
}
}
}
Then run with-
perl thisscript yourinputfile >resultfile
HTH
-- Rod Hills