- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: I want to grep some pattern.
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
11-30-2005 11:51 PM
11-30-2005 11:51 PM
I want to grep some pattern.
I want to grep for one pattern and associated time stamp from a log file..
####
> <101020> <[ServletContext(id=3078349,name=webapperer,context-path=/webapperee)] Servlet failed with Exception>
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start(Native Method)
Iam looking for below output:-
Dec 1, 2005 2:20:28 AM PST :OutOfMemoryError : blaa.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2005 11:53 PM
11-30-2005 11:53 PM
Re: I want to grep some pattern.
try
grep OutofMemory blaa.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2005 11:54 PM
11-30-2005 11:54 PM
Re: I want to grep some pattern.
You could keep this as simple as:
# grep -i -e "Dec 1" -e "OutofMemoryError" logfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 12:45 AM
12-01-2005 12:45 AM
Re: I want to grep some pattern.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 01:52 AM
12-01-2005 01:52 AM
Re: I want to grep some pattern.
Which will solve my problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 02:34 AM
12-01-2005 02:34 AM
Re: I want to grep some pattern.
perl and awk will do, but you cannot grep in one regex (in perl you could, but then you will have to change the input line separator, and things will get quite unreadable fast :)
In the next line, $p is the previous line:
# perl -nle'$p=~/pattern_for_previous_line/&&/<(.*?)>.*?(\w*OutOfMemoryError)/ and print "$1 : $2 : $ARGV\n(previous line is $p)\n";$p=$_' blaa.log
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 03:18 AM
12-01-2005 03:18 AM
Re: I want to grep some pattern.
Not sure if grep can print lines above those that match a pattern but ex can:
# ex -s input_file <
> EOF
regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 08:27 PM
12-01-2005 08:27 PM
Re: I want to grep some pattern.
you can use sed:
# print the line immediately before and the line containing regexp
sed -n -e '/regexp/{x;1!p;g;p;}' -e h file
in your case:
sed -n -e '/OutOfMemoryError/{x;1!p;g;p;}' -e h blaa.log
HTH,
Art