Need Help for interval date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help for interval date
# 1  
Old 01-19-2009
Need Help for interval date

Hello,
I need help about a shell script
I have a text file with this fields:

2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:40: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:48: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:58: --> ---ORA-28817: PL/SQL function returned an error.

I know the second field.

Ec. Giving the interval:
09:33:40 and
09:33:58
how I take only the rows between this interval ?


I'm trying with sed and grep but nothing....

Thanks for the help
# 2  
Old 01-19-2009
With awk:

Code:
awk '/09:33:40/{f=1;next}/09:33:58/{exit}f' file

Regards
# 3  
Old 01-19-2009
Quote:
Originally Posted by giofai
Hello,
Ec. Giving the interval:
09:33:40 and
09:33:58
how I take only the rows between this interval ?
Code:
$ nawk '{gsub(/:/,"",st);gsub(/:/,"",et);gsub(/:/,"",$2);if($2>=st && $2<=et) print }' st=09:33:40 et=09:33:58 infile
2009/01/19 093340 --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 093348 --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 093358 --> ---ORA-28817: PL/SQL function returned an error.
$

# 4  
Old 01-20-2009
#!/bin/ksh
. ./was.env
dt=$(date +"%m"-"%d"-"%Y"-"%H":"%S")
while :
do
#a=`cat $log_dir/$app_name.pid | cut -d "" -f1 `
if [ -f $log_dir/$app_name.pid ]
then
break
else
echo "~~~~~~~~~~~~~~~~~~~PID Not Found~~~~~~~~~~~~~~~~~~~~~~~~" >>$report_dir/$app_name.$dt.log
tail -100 $log_dir/SystemOut.log >> $report_dir/$app_name.$dt.log
break
fi
done
===========================================

cat was.env
app_name=sys
log_dir=/home/justus/scripts/log
report_dir=/home/justus/scripts/report
# 5  
Old 01-20-2009
flag=0
while read line
do

part=`echo $line | cut -d " " -f2`

if [ $part = "09:33:58:" ]
then
flag=0
fi

if [ $flag -eq 1 ]
then
echo $line
fi
if [ $part = "09:33:40:" ]
then
flag=1
fi
done < ./test_file






cat ./test_file

2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:40: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:48: --> ---ORA-28817: PL/SQL function returned an error.
2009/01/19 09:33:58: --> ---ORA-28817: PL/SQL function returned an error.



./extract_line.sh
2009/01/19 09:33:48: --> ---ORA-28817: PL/SQL function returned an error.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Repetition in a particular interval

Suppose I have a word which is repeating in a string continuously. I have a set of intervals. Then how do I find the number occurrences of that word in those intervals and their location of occurrences. For example - Suppose there is a huge string anfie.......sirn of 10000 letters. Now the word... (2 Replies)
Discussion started by: ANKIT ROY
2 Replies

2. Shell Programming and Scripting

Interval merging

I do have a file (file1) with a specified interval of 500 counts file1 0 500 500 1000 1000 1500 1500 2000 2000 2500 2500 3000 3000 3500 3500 4000 4000 4500 4500 5000 5000 5500 5500 6000 6000 6500 6500 7000 7000 7500 7500 8000 (3 Replies)
Discussion started by: Kanja
3 Replies

3. Shell Programming and Scripting

While loop in certain interval

Hi Gurus, I have a script which loops a directory to find the file. right now, I want to add time interval which means every 15 minutes it checks the dir once. if all files are found, then exit with 0. if there are some files missing at 6:00am the process exit with 20. the script start at 7:00pm... (15 Replies)
Discussion started by: ken6503
15 Replies

4. Shell Programming and Scripting

Script (ksh) to get data in every 30 mins interval for the given date

Hello, Since I m new to shell, I had a hard time to sought out this problem. I have a log file of a utility which tells that batch files are successful with timestamp. Given below is a part of the log file. 2013/03/07 00:13:50 Apache/1.3.29 (Unix) configured -- resuming normal operations... (12 Replies)
Discussion started by: rpm120
12 Replies

5. Shell Programming and Scripting

counts for every 1000 interval

Hi, I have a file with 4 million rows. Each row has certain number ranging between 1 to 30733090. What I want is to count the rows between each 1000 intervals. 1-1000 4000 1001-2000 2469 ... ... ... ... last 1000 interval Thanks, (7 Replies)
Discussion started by: Diya123
7 Replies

6. Solaris

NTP polling interval

Is it possible to change the ntp poll manually. I notice that ntp poll is changing autimatically. (1 Reply)
Discussion started by: ningy
1 Replies

7. Programming

Interval year to month

Hi, I'm working on a Informix4gl module. I'm just trying to find out any built-in function to fetch only the year/month from an INTERVAL YEAR TO MONTH data value. Please let me know, if there are any functions to do this. If not, let me know for any alternative solutions to attain this. ... (5 Replies)
Discussion started by: dvah
5 Replies

8. Shell Programming and Scripting

compare the interval of 2 numbers of input2with interval of several numbers of input1

Help plz Does any one have any idea how to compare interval ranges of 2 files. finding 1-4 (1,2,3,4) of input2 in input1 of same key "a" values (5-10, 30-40, 45-60, 80-90, 100-120 ). Obviously 1-4 is not one of the range with in input1 a. so it should give out of range. finding 30-33(31,32,33)... (1 Reply)
Discussion started by: repinementer
1 Replies

9. UNIX for Advanced & Expert Users

Summation of the column value in an interval.

Hey, I have a file with following data.. and I want to get the summation of 10th column. And this happens in every 10 seconds for a minute max. 242001 A mqsitst 794864 1249516 0 60 20 293050400 77016 * 02:05:33 - 0:04 DataFlowEngine EAITIBR2_BROKER... (6 Replies)
Discussion started by: varungupta
6 Replies

10. Shell Programming and Scripting

To extract data of a perticular interval (date-time wise)

I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)
Discussion started by: abhishek27
3 Replies
Login or Register to Ask a Question