- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to split a large file
Operating System - HP-UX
1753467
Members
5105
Online
108794
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
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
08-04-2004 02:37 AM
08-04-2004 02:37 AM
Re: How to split a large file
Hmmm... this problem is much similar to:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=654588
Oracle alert files have times stamps like:
Fri Jun 25 14:19:13 2004
I'd use a perl script (let's call it alert-by-month.pl) similar to
if (/^\w+\s+(\w+)\s+\d+\s\d+:/) {
if ($month ne $1) {
$month = $1;
open(M,">alert_$month.log") or die;
}
}
print M;
So it looks for lines starting with a word [the day: \w+] followed by whitespace.
It remembers the next word in $1 [the month: (\w+)]
Then, to be sure it is a date stamp is looks for whitespace, numbers, whitespace, numbers, colon" : [day,hour,":" : \s+\d+\s\d+: ]
When it sees that, it compares the new month (in $1) with the current month.
If it is a new month (like the first line!), then it makes that the current month and opens a new output file.
Finally it prints the line on the current file.
Now exectute with:
perl -n alert-by-month.pl alert
Good luck.
Hein
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=654588
Oracle alert files have times stamps like:
Fri Jun 25 14:19:13 2004
I'd use a perl script (let's call it alert-by-month.pl) similar to
if (/^\w+\s+(\w+)\s+\d+\s\d+:/) {
if ($month ne $1) {
$month = $1;
open(M,">alert_$month.log") or die;
}
}
print M;
So it looks for lines starting with a word [the day: \w+] followed by whitespace.
It remembers the next word in $1 [the month: (\w+)]
Then, to be sure it is a date stamp is looks for whitespace, numbers, whitespace, numbers, colon" : [day,hour,":" : \s+\d+\s\d+: ]
When it sees that, it compares the new month (in $1) with the current month.
If it is a new month (like the first line!), then it makes that the current month and opens a new output file.
Finally it prints the line on the current file.
Now exectute with:
perl -n alert-by-month.pl alert
Good luck.
Hein
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 02:51 AM
08-04-2004 02:51 AM
Re: How to split a large file
Scott -- using the data provided above, here is a solution.
Create a script file called "do":
echo MONTH $1 > .do1
cat $2 >> .do1
awk -f pull_month.awk < .do1 > .do3
mv .do2 archived_data.log
mv .do3 new_data.log
rm .do1
Create an awk file called pull month :
/^MONTH/ {targetmonth=$2;next;}
$2==targetmonth {print $0 > ".do2";next}
{print $0}
Run it as:
do Jun
Example:
do Jun usek
usek contains:
Fri Jun asdf asdf asdf asdfasdf
Fri Jun asdf asdf asdf asdfasdf
Fri Jul asdf asdf asdf asdfasdf
Fri Jul asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
after the run, archived_data_log contains:
Fri Jun asdf asdf asdf asdfasdf
Fri Jun asdf asdf asdf asdfasdf
after the run, new_data_log contains:
Fri Jul asdf asdf asdf asdfasdf
Fri Jul asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
Create a script file called "do":
echo MONTH $1 > .do1
cat $2 >> .do1
awk -f pull_month.awk < .do1 > .do3
mv .do2 archived_data.log
mv .do3 new_data.log
rm .do1
Create an awk file called pull month :
/^MONTH/ {targetmonth=$2;next;}
$2==targetmonth {print $0 > ".do2";next}
{print $0}
Run it as:
do Jun
Example:
do Jun usek
usek contains:
Fri Jun asdf asdf asdf asdfasdf
Fri Jun asdf asdf asdf asdfasdf
Fri Jul asdf asdf asdf asdfasdf
Fri Jul asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
after the run, archived_data_log contains:
Fri Jun asdf asdf asdf asdfasdf
Fri Jun asdf asdf asdf asdfasdf
after the run, new_data_log contains:
Fri Jul asdf asdf asdf asdfasdf
Fri Jul asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
Fri Aug asdf asdf asdf asdfasdf
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
- « Previous
-
- 1
- 2
- Next »
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