- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl Question Reading Log File
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
тАО08-30-2002 06:25 AM
тАО08-30-2002 06:25 AM
example-
ERROR: There was a problem
USER: This user caused the problem
DATE: Todays date and time
I would like to key on ERROR, but I also want the USER and DATE. I know how to do this with awk, but I want it portable to Windows. So I figure Perl would be more portable. Can anyone give an example of how to do this if it is possible.
Thanks,
Jason Berendsen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2002 06:38 AM
тАО08-30-2002 06:38 AM
Re: Perl Question Reading Log File
perl -ne '/ERROR:/ && do {$cnt=3;} ; print $_ if $cnt--' yourlogfile
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2002 09:12 AM
тАО08-30-2002 09:12 AM
Re: Perl Question Reading Log File
I must be doing something wrong. Here is the test file I am using:
This shouldn't show line 1
This shouldn't show line 2
This shouldn't show line 3
This shouldn't show line 4
ERROR: There was a problem
USER: This user caused the problem
DATE: Todays date and time
This shouldn't show line 8
This shouldn't show line 9
This shouldn't show line 10
This shouldn't show line 11
I am hoping only to pull lines 5 thru 7. This is the output I get from your logic:
This shouldn't show line 2
This shouldn't show line 3
This shouldn't show line 4
ERROR: There was a problem
USER: This user caused the problem
DATE: Todays date and time
This shouldn't show line 9
This shouldn't show line 10
This shouldn't show line 11
Lines 1 and 8 are missing but 2,3,4,9,10 and 11 still show. Is there a way to just have the ERROR: line as well as the two lines after it?
Thanks for the help,
Jason
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2002 09:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2002 10:35 AM
тАО08-30-2002 10:35 AM