script to grep latest outofmemory string from the logs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to grep latest outofmemory string from the logs
# 8  
Old 12-16-2010
Code:
 
echo "$error" | sed 's/.*: \(.*\)/\1/g'

\1 is Backreferencing what matched inside \( and \)
It should print
Code:
 
Java heap space

# 9  
Old 12-16-2010
Hello Anurag

I am not getting any output for that command and just getting sed command garbled error.

Code:
bash-3.00$ echo $error | sed 's/.*:(.*)$/\1/g'
sed: command garbled: s/.*:(.*)$/\1/g
bash-3.00$

kindly suggest the solution.
# 10  
Old 12-16-2010
Quote:
Originally Posted by coolguyamy
Hello Anurag

I am not getting any output for that command and just getting sed command garbled error.

Code:
bash-3.00$ echo $error | sed 's/.*:(.*)$/\1/g'
sed: command garbled: s/.*:(.*)$/\1/g
bash-3.00$

kindly suggest the solution.
What Anurag has suggested? He asked you to escape ( and ) characters. Did you try that?

Code:
echo "$error" | sed 's/.*:\(.*\)$/\1/g'

If its not working, which shell u r using?
R0H0N
# 11  
Old 12-16-2010
Code:
echo "$error" | sed 's/.*: \(.*\)/\1/g'

Also a single space between : and \(
To discard space in front in output

Last edited by anurag.singh; 12-16-2010 at 09:15 AM..
# 12  
Old 12-16-2010
Hello Rohan,

I have tried sugesstion by Anurag and i am getting following output now.

Code:
bash-3.00$ echo "$error" | sed 's/.*: \( .*\)$/\$1/g'
[12/14/10 14:46:15:086 CET] 00000041 webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[springDispatcherServlet]: java.lang.OutOfMemoryError: Java heap space
bash-3.00$

# 13  
Old 12-16-2010
What's wrong with just:
Code:
echo $error | "s/.*: //"

Where does the last "OutOfMemory" error fit into this?
# 14  
Old 12-16-2010
Hello Scottn,

Thanks for the response. I have ran the command and it's giving java heap space as output.

can you please tell me how to get outofmemory from the output.

Code:
bash-3.00$ echo "$error" | sed "s/.*: //"
Java heap space

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. UNIX for Beginners Questions & Answers

Grep a pattern & Email from latest logs

MyLOG: 2017/11/12 17:01:54.600 : Error: LPID: 3104680848 WRONG CRITERIA FOUND. tRealBuilder::Generate Output Required: If Ke word "WRONG CRITERIA FOUND" in latest log ( logs are regularly generating - real time) mail to us once mailed wait for 2 hours for second mail. mail subject... (3 Replies)
Discussion started by: vivekn
3 Replies

3. Shell Programming and Scripting

Search string or words in logs without using Grep

I'm in need of some kind of script that will search for a string in each logfile in a directory but we don't want to use GREP. GREP seems to use up to much of our memory causing the server to use up a lot of swap space. Our log files are bigger than 500M on a daily basis. We lately started... (8 Replies)
Discussion started by: senormarquez
8 Replies

4. Shell Programming and Scripting

Script to grep logs for Errors

Hi Guys, I want to write a script which can grep the logs (server.log) from a file for Error String and output to a other file. Problems: How to know about the errors only between the current restart and not in previous as server.log has earlier restarts also? thanks for the help! Much... (5 Replies)
Discussion started by: ankur328
5 Replies

5. Shell Programming and Scripting

To find latest set of logs among new and old

Hi All I am writing a script which will select the latest logs (which are generated every night via a script) among old one and new. Script generates set of 3 logs each time it runs. Example : log-WedJun082011_bkt1.log log-WedJun082011_bkt2.log log-WedJun082011_bkt3.log I have... (1 Reply)
Discussion started by: ratneshnagori
1 Replies

6. Shell Programming and Scripting

shell script to grep 500 error messages from access logs

Hello Team, I need help to improve my script which is used to grep 500 error messages in the logs. I am using following logic in the script to grep 500 error messages in the logs. var1=`awk '$9 == "500"' access_log | tail -1` The above logic is not useful if logs are not getting... (1 Reply)
Discussion started by: coolguyamy
1 Replies

7. Shell Programming and Scripting

script to grep outofmemory message in logs

I have prepare script to grep for outofmemory messages in the logs. I need help in modifying script. I have implemented small logic. The outofmemory messages form six logs will store in variables. var1=`grep -i outofmemory $tomcat1logs | sed -n '$p'| sed -n -e "s/.*\(outofmemory\).*/\1/p"`... (6 Replies)
Discussion started by: coolguyamy
6 Replies

8. Shell Programming and Scripting

Grep string from logs of last 1 hour on files of 2 different servers and calculate count

Hi, I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files. File structure is same on both servers and for reference as follows: 27-Aug-2010... (4 Replies)
Discussion started by: poweroflinux
4 Replies

9. UNIX for Dummies Questions & Answers

grep -c script counting string twice instead of once?

I tried this script to get a count of the occurrence of a string in files. I have multiple files in one directory I will use this on. All the filenames begin "invALL.06" The script works, except it counts twice for every one instance of 'Invoice Total'. If there are 5 occurences of 'Invoice... (2 Replies)
Discussion started by: scarletsupra
2 Replies

10. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies
Login or Register to Ask a Question