Searching a specific line in a large file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching a specific line in a large file
# 1  
Old 07-07-2008
Searching a specific line in a large file

Hey All

Can any one please suggest the procedure to search a part of line in a very large file in which log entries are entered with very high speed.

i have trued with grep and egrep

grep 'text text text' <file-name>

egrep 'text text text' <file-name>

here 'text text text' is something which i have selected from file itself
# 2  
Old 07-07-2008
Code:
tail -f thatlogfile | grep "text text text" > filteredlog
# or to see it on the screen and write it parallel into a file
tail -f thatlogfile | grep "text text text" | tee filteredlog

# 3  
Old 07-07-2008
need some more help !!!

Thanks Zaxxon

Actually our requirement is to find a specific error line in a very lagre log file which is heavily appended with many log entries.
And on every occurenceof the error we have to sent a mail alert .

please suggest
# 4  
Old 07-07-2008
Here is some idea to do this --
--------------------------------
ls -1 | while read record;do
rv=`echo $record | grep -w "ERROR-STRING"`
if [ $? -eq 0 ]
then
mailx -s "Error found in record - $record " xxxx@yourcompany.com
fi
done
# 5  
Old 07-10-2008
Thanks all,

i have used
grep 'text to be searched' $myFile > test

as using tail -f $myFile | grep 'error'

im unable to set a exit condition.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash : Checking Large file for specific lines

Morning .. I have a file with approximately 1000 lines. I want to check that the file contains, for example, 100 lines. Something like whats given below is ugly. And even if I create a function I have to call it 100 times. I may need to look through multiple files at times. Is there a... (4 Replies)
Discussion started by: sumguy
4 Replies

2. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

3. Shell Programming and Scripting

Searching a large file for short tandem repeats

Hello, I am searching large (~25gb) DNA sequence data in fasta short read format: >ReadName ACGTACGTACGT... for short tandem repeats, meaning instances of any 2-6 character based run that are repeated in tandem a number of times given as an input variable. Seems like a reasonably simple... (3 Replies)
Discussion started by: ljk
3 Replies

4. Red Hat

Moving of file content to another two files after searching with specific pattern

Hello, Please help me with this!! Thanks in advance!! I have a file named file.gc with the content: 1-- Mon Sep 10 08:53:09 CDT 2012 2revoke connect from FR2261; 3delete from mkt_allow where grantee = 'FR2261'; 4grant connect to FR2261 with '******'; 5alter user FR2261 comment... (0 Replies)
Discussion started by: raosr020
0 Replies

5. Shell Programming and Scripting

Searching for a specific string in a file

Hi I am trying to search for a certain set of patterns within a file, and then perform other commands based on output. testfile contents: password requisite pam_cracklib.so lcredit=-1 ucredit=-1 ocredit=-1 script: D="dcredit=-1" if then echo $D exists else echo $D doesnt... (8 Replies)
Discussion started by: bludhemn
8 Replies

6. Shell Programming and Scripting

remove a specific line in a LARGE file

Hi guys, i have a really big file, and i want to remove a specific line. sed -i '5d' fileThis doesn't really work, it takes a lot of time... The whole script is supposed to remove every word containing less than 5 characters and currently looks like this: #!/bin/bash line="1"... (2 Replies)
Discussion started by: blubbiblubbkekz
2 Replies

7. Shell Programming and Scripting

Count specific character(s) very large file

I'm trying to count the number of 2 specific characters in a very large file. I'd like to avoid using gsub because its taking too long. I was thinking something like: awk '-F' { t += NF - 1 } END {print t}' infile > outfile which isn't working Any ideas would be great. (3 Replies)
Discussion started by: dcfargo
3 Replies

8. UNIX for Dummies Questions & Answers

Help with selecting specific lines in a large file

Hello, I need to select the 3 lines above as well as below a search string, including the search string. I have been trying various combinations using sed command without any success. Can anuone help please. Thanking (2 Replies)
Discussion started by: tansha
2 Replies

9. UNIX for Dummies Questions & Answers

viewing and searching large file

I need to search a very large file. 13g in size. i am looking for a record that has a value in the byte 4200 . how can i view the file or how can i search for value in the byte 4200? (1 Reply)
Discussion started by: Wrightman
1 Replies

10. Shell Programming and Scripting

Searching for data on a specific line numbers

Hi, I have a file on windows and have some unix utilitties available on windows. This file is very large and have over 5 million record. I am not able to open this file in Window Editor. I am trying to see bad data on a specific lines. I just have line numbers that has bad data. I need to see the... (8 Replies)
Discussion started by: rkumar28
8 Replies
Login or Register to Ask a Question