Grep Segmentation Fault If statement


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep Segmentation Fault If statement
# 1  
Old 05-30-2012
Grep Segmentation Fault If statement

I receive a segmentation fault on some servers when grepping a string, but not when I use -i, and vice-versa. I have googled this and realise it is usually a hardware / memory issue.

I'd like to write an if statement that says "if grep string returns 'Segmentation fault' then grep the same string with -i".

I tried assigning the value of the grep statement to a variable but it's not storing the "Segmentation fault" error.

SEARCH="`zgrep -i search_string /path/to`"

How can I check for this when grepping? Is Segmentation fault from stderr?
# 2  
Old 05-30-2012
It sounds more like a software bug to me, if it happens on more than one system. Try upgrading your version of grep.

If it really is a hardware problem, your entire system is suspect and you should fix it at once before something terrible happens, instead of trying to ignore and work around the burning engine...
# 3  
Old 05-30-2012
Company machines so I can't do anything with them. Any help w/ that condition?
# 4  
Old 05-30-2012
Maybe you can use alternatives like awk or perl, or a different regex. Anything's better than an if-statement for "in case this crummy program crashes", which again, is like an if-statement for "in case the engine explodes, how to keep going". What's your regex?

Last edited by Corona688; 05-30-2012 at 03:35 PM..
# 5  
Old 05-31-2012
It's like this:
Code:
zgrep "$1" /path/to/search/"$2"*|sed 's/\#20/ /g'|proprietary_command_to_format_log_output | egrep -v "unwanted_strings"

We typically have this menu to do all log searches but I have this little kludge which makes it easier. The only thing is sometimes I get a memory fault depending on if I use -i or not.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Solaris

Segmentation fault

Hi Guys, I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error: "Segmentation fault" Can someone please help me resolve this? Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies

3. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

4. UNIX for Advanced & Expert Users

segmentation fault with ps

What does this mean and why is this happening? $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps aux | grep ocular Segmentation fault (core dumped) $ ps Segmentation fault (core dumped) $ pkill okular $ ps... (1 Reply)
Discussion started by: cokedude
1 Replies

5. Programming

segmentation fault.

This code is causing a segmentation fault and I can't figure out why. I'm new to UNIX and I need to learn how to avoid this segmentation fault thing. Thank you so much. Thanks also for the great answers to my last post.:):b: int main() { mysqlpp::Connection conn(false); if... (3 Replies)
Discussion started by: sepoto
3 Replies

6. Programming

segmentation fault

What is segmentation fault(core dumped) (1 Reply)
Discussion started by: gokult
1 Replies

7. Programming

segmentation fault

Hi, I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
Discussion started by: mind@work
3 Replies

8. Programming

Why not a segmentation fault??

Hi, Why I don't receive a segmentation fault in the following sample. int main(void) { char buff; sprintf(buff,"Hello world"); printf("%s\n",buff); } If I define a buffer of 10 elements and I'm trying to put inside it twelve elements, Should I receive a sigsev... (22 Replies)
Discussion started by: lagigliaivan
22 Replies

9. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

10. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies
Login or Register to Ask a Question