String search in log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String search in log file
# 1  
Old 07-12-2006
String search in log file

Hi all!

I have a log file from an incremental backup. This next script I've done works when the backup completes in the same day it started. But if the backup goes on to the next day, this one doesn't work anymore.

##################################
#VARS
data=`date '+%m/%d/%y'`
directoria='/var/local/logs/backup'
###################################
select versao in diario semanal mensal
do
case $versao in
diario) grep $data $directoria/dsmsched_diario.log > $directoria/back.log;;
semanal) grep $data $directoria/dsmsched_semanal.log > $directoria/back.log
;;
mensal) grep $data $directoria/dsmsched_mensal.log > $directoria/back.log;;
*) print "As opcoes sao 1,2 e 3"; break;;
esac
done
more $directoria/back.log
rm $directoria/back.log



Log file looks like this

07/05/06 23:58:17 Normal File--> 1,048,580,096 /ONLINE/u03/oradata/HIST_EI
/eigraciosatab01.dbf [Sent]
07/05/06 23:59:41 Normal File--> 1,048,580,096 /ONLINE/u03/oradata/CTTSITE
/moverstab01.dbf [Sent]
07/06/06 00:00:09 Normal File--> 734,007,296 /ONLINE/u03/oradata/EI_PDL/
eitab01.dbf [Sent]
07/06/06 00:00:34 Normal File--> 209,719,296 /ONLINE/u03/oradata/CTTSITE
/questtab.dbf [Sent]
delete
# 2  
Old 07-12-2006
I've solved... I used egrep command. egrep let use two strings in same command. Tkz anyway
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search partial string in a file and replace the string - UNIX

I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this. string(Scenario 1)- user::r--,user::ourfrd:r-- String(Scenario 2)- user::r-- File **** # file: /local/Desktop/myfile # owner: me # group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies

2. UNIX for Beginners Questions & Answers

Search a string and display its location on the entire string and make a text file

I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file. Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies

3. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

4. UNIX for Dummies Questions & Answers

Search for a specific String in a log file for a specific date range

Hi, I have log file which rolls out every second which is as this. HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
Discussion started by: karthikprakash
3 Replies

5. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

6. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

7. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

8. Shell Programming and Scripting

String search in log file

hi, i have a requirement to search for a sting "/user/data/<7digit>/<temp dir>/<file name>#<unique string> in a log file. This string present number of times but i need to get the first occurence only. i am trying with the below option but not working can you please help. grep... (1 Reply)
Discussion started by: Satyak
1 Replies

9. Shell Programming and Scripting

search string in a file and retrieve 10 lines including string line

Hi Guys, I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same. can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies

10. Shell Programming and Scripting

appending string to text file based on search string

Hi, I need to append string "Hi" to the beginning of the lines containing some specific string. How can I achieve that? Please help. Malay (1 Reply)
Discussion started by: malaymaru
1 Replies
Login or Register to Ask a Question