Shell scripting to extract data from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell scripting to extract data from file
# 1  
Old 03-22-2010
Shell scripting to extract data from file

Hi,

i want to fetch the data from the alert log file, for a particular time interval.

Example :

Alert log content :


Code:
Thu Mar 18 08:47:36 2010
Completed: alter database open
Thu Mar 18 19:13:38 2010
MMNL absent for 6390 secs; Foregrounds taking over
Fri Mar 19 08:30:52 2010
MMNL absent for 44823 secs; Foregrounds taking over
Fri Mar 19 10:49:26 2010
ALTER TABLESPACE SYSTEM COALESCE
Fri Mar 19 10:49:26 2010
Completed: ALTER TABLESPACE SYSTEM COALESCE
Fri Mar 19 10:49:35 2010
ALTER TABLESPACE SYSTEM COALESCE
Completed: ALTER TABLESPACE SYSTEM COALESCE
Fri Mar 19 10:49:54 2010
ALTER TABLESPACE SYSAUX COALESCE
Fri Mar 19 10:49:54 2010
Completed: ALTER TABLESPACE SYSAUX COALESCE
Mon Mar 22 00:16:33 2010
MMNL absent for 198455 secs; Foregrounds taking over

I want to do a periodic check say every 5 hours to check the content of the alert.log,that is copy the content from Mar18th 00:00:00 to 05:00:00 to a file. then at 5 o'clock i run my script again, then i need the contents from Mar18th 05:00:00 to 10:00:00.( Irrespective, of if there is any enrty made at Mar18th 05:00:00 .)

please guide me on this.

Let me know, if i am not clear with my query.

Thanks in advance!!!

Last edited by joeyg; 03-22-2010 at 10:02 AM.. Reason: code tags, please...; & provide more info in "title"
# 2  
Old 03-22-2010
Error

Code:
cd MY_PATH
date=`date +'%Y-%m-%d'`
time=`date +'%H:%M:%S %Z'`
cp -p alert.log ./BACK/alert_$date_$time.log
> alert.log

you can put this in a script and schedule via cron to run every 5 hours...

is that what you want ?

Abhi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to extract data in a file

I have this 5GB file, and i want to extract from the file particulars pattern. this is my script: // count=`grep -wc "MSISDN" file_name` k=1 >OUTPUT >OUTPUT_Final while do cat file_name | awk -F":" -v var="$k" '$1=="MSISDN" {m++}m==var{print; exit}' >> OUTPUT cat file_name |awk -F":"... (33 Replies)
Discussion started by: gillesi
33 Replies

2. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

3. Shell Programming and Scripting

Shell script to extract data from csv file

Hi everyone, I have a csv file which has data with different heading and column names as below. Static Data Ingested ,,,,,,,,,,,,Known Explained Rejections Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10 ,... (14 Replies)
Discussion started by: Vivekit82
14 Replies

4. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 7 columns having values say column 1,column 2.....column 7 as below along with their values. Name, Address,... (7 Replies)
Discussion started by: Vivekit82
7 Replies

5. Shell Programming and Scripting

How to extract data from XML file using shell scripting?

Hi , I have input file as XML. following are input data #complex.xml Code: <?xml version="1.0" encoding="UTF-8"?><TEST_doc xmlns="http://www.w3.org/2001/XMLSchema-instance"> <ENTRY uid="123456"> <protein> <name>PROT001</name> <organism>Human</organism> ... (1 Reply)
Discussion started by: arun_kohan
1 Replies

6. Shell Programming and Scripting

How to extract data from xml file using shell scripting?

Hi evry1, This is my 1st post in this forum.Pls help me I want to extract some data froma xml file which has 2000 lines using shell scripting. Actually my xml file has some "audio and video codes" which i need to arrange in a column wise format after extracting it using shell scripting.I... (4 Replies)
Discussion started by: arun_kohan
4 Replies

7. Shell Programming and Scripting

Replace data of a file with data from another file using shell scripting.

Dears, I'm new to shell scripting and i was wondering if you can help me with following matter. I have a file containing 400,000 records. The file contains two columns like: 00611291,0270404000005453 25262597,1580401000016155 25779812,1700403000001786 00388934,1200408000000880... (1 Reply)
Discussion started by: paniklas
1 Replies

8. Shell Programming and Scripting

Extracting data from file-shell scripting--please help

hello friends, my file is like 123 |asd|asd|asd 123_1|awd|asw|asw 121 |wer|qwe|wee 124 |weq|qwe|iop 1_23 |bla|blh|bha 145 |ghj|jkl|ghj 146 |qwe|qwe|wer 154 |asd|wer|qw_e 134_5|qwe|wer|qw_e is their any solution to retrive only those lines which are having only 3 numerical letters... (20 Replies)
Discussion started by: PankajChawla
20 Replies

9. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

10. Shell Programming and Scripting

shell-script which extract data from log file

give me a shell-script which extract data from log file on a server by giving date and time as input (for both start time and end time) and it will give the logs generated during the given time as output. (4 Replies)
Discussion started by: abhishek27
4 Replies
Login or Register to Ask a Question