from the above logfile i need to get the lines between the two timestamps,if i give
Code:
2013-08-02 (start) & 2013-08-05 (end)
i am getting the content.
But wen i give
Code:
2013-08-01 (start) and 2013-08-05 (end)
i didnt get the output.
my reqiurement is even though 2013-08-01 is not there wen i give 2013-08-01 as start date it should calculate and give the lines.
Please help me guys.
I think this can be done through some date manipulation.
st="2013-08-01"
en="2013-08-03"
awk -v ST="$st" -v EN="$en" '
{
V = $1
gsub ( "-", X, V )
gsub ( "-", X, ST )
gsub ( "-", X, EN )
if ( V >= ST && V <= EN )
print
}
' file.log
st="2013-08-01"
en="2013-08-03"
awk -v ST="$st" -v EN="$en" '
{
V = $1
gsub ( "-", X, V )
gsub ( "-", X, ST )
gsub ( "-", X, EN )
if ( V >= ST && V <= EN )
print
}
' file.log
recommend to move below lines to BEGIN{} part in awk, which will avoid to gsub on each line again.
Code:
gsub ( "-", X, ST )
gsub ( "-", X, EN )
These 2 Users Gave Thanks to rdcwayx For This Post:
Hi guys thanks for your reply,
when i run the above script i didnt get any output.
Code:
[ 2013-08-02 04:01:23 pid=15642 ppid=15642 ] Exited the Programme
[ 2013-08-02 03:59:14 pid=15690 ] Exited the Programme, recovery completed
[ 2013-08-03 09:15:37 pid=21374 ] Exited the Programme, recovery completed
[ 2013-08-03 09:19:49 pid=21773 ] Exited the Programme, recovery
[ 2013-08-04 09:26:44 pid=22199 ] Exited the Programme, recovery completed
the code i run is
Code:
#!/bin/ksh
st="2013-08-01"en="2013-08-03"awk -v ST="$st" -v EN="$en" '{V = $1gsub ( "-", X, V )gsub ( "-", X, ST )gsub ( "-", X, EN )if ( V >= ST && V <= EN )print}' recovery.log
Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below.
Could you please help out to achieve solution through shell script..
File content:
... (2 Replies)
Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" .
I have attached sample input file and the desired input should be as:
INPUT FORMAT:
SELECT
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,... (5 Replies)
Dear all,
I have an user passing 2 parameter 31/03/2015 and 02/04/2015 to a ksh script. How to print the start date to end date.
Expected output is :
31/03/2015
01/04/2015
02/04/2015
Note :
1. Im using aix and ksh
2. I have tried to convert the given input into a date, didnt... (0 Replies)
Hi,
I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Hi All,
what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case
week start date will be-:12/19/2011... (2 Replies)
Hi All,
Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl?
(To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Hi All,
I enter Start date and end date as parameters. I need to capture dates between start date and end date. Please let me know if you have any idea the same.
Thanks in advance.
Nagaraja Akkivalli. (5 Replies)