- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Perl script extension
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-11-2005 08:08 PM
08-11-2005 08:08 PM
I have a last question on the script provided by Hein below, http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=947337.
Is it possible to extract the pattern for all the file in a directory starting with ABC for example and store the result in one file?
$serial = shift @ARGV or die "please provide serial number to select on";
while (<>) {
if (/^flag_start/) {
$save = 1;
$file = 0;
undef @lines;
}
if (/^flag_stop/) {
$save = 0;
push @lines, $_;
if ($file) {
print while ($_ = shift @lines );
}
print "\n";
}
push @lines, $_ if $save;
$file++ if /$serial/;
}
Thanks in advance for your help
Best Regards
Jerome
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 08:28 PM
08-11-2005 08:28 PM
Re: Perl script extension
a. glob ()
b. magic diamond
c. local @ARGV
a. my @files = glob "ABC*";
b. my @files =
c. local @ARGV = (
# perldoc -f glob
# man perlvar
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 08:29 PM
08-11-2005 08:29 PM
Re: Perl script extension
Put this in a script file called,
#extrac.pl
$serial = shift @ARGV or die "please provide serial number to select on";
while (<>) {
if (/^flag_start/) {
$save = 1;
$file = 0;
undef @lines;
}
if (/^flag_stop/) {
$save = 0;
push @lines, $_;
if ($file) {
print while ($_ = shift @lines );
}
print "\n";
}
push @lines, $_ if $save;
$file++ if /$serial/;
}
# end #
# perl extract.pl ABC* > serial_no1.log
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 08:34 PM
08-11-2005 08:34 PM
Solution# perl extract.pl
while (<>){} - will get data from all input files.
Example:
# perl extract.pl Serialkey1 ABC* > serialkey.tmp
There is another solution in this thread,
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=947337
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2005 09:00 PM
08-11-2005 09:00 PM
Re: Perl script extension
It is working now ... ;)
Jerome