awk - check time stamp between range or not


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk - check time stamp between range or not
# 1  
Old 07-15-2013
IBM awk - check time stamp between range or not

I want to check given time stamp is between the given time stamp or not. I am using AIX.

YYYYMMDDHHMMSS
abc.csv
START TIME, END TIME
20130209018000,20130509022000
20120209018000,20130509022000
20120209018000,20130509022000

Script will check given time stamp is between above two range or not.
Eg: 20130509022000
Will return rows from abc.csv where time stamp is between or equal to start time & end time.

Please advise.
# 2  
Old 07-15-2013
Code:
ts=$1

awk -F, -v T="$ts" 'NR > 1 && T >= $1 && T <= $2' abc.csv

This User Gave Thanks to Yoda For This Post:
# 3  
Old 07-16-2013
thanks! will check it.

Last edited by vegasluxor; 07-16-2013 at 02:26 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Time Stamp Range On Log Files

I have created this script #!/bin/sh FILES=/data/log/access_*.log for f in $FILES do echo "Processing $f file" cat $f | awk '{print $1}' | sort | uniq -c | sort -n | tail done It produces this output Processing /data/log/access_abc.log file 114 1.1.1.1 167 2.2.2.2 ... (38 Replies)
Discussion started by: sharingsunshine
38 Replies

2. Shell Programming and Scripting

To check time stamp in log file and calculate.

Hi Friends, I have the following logfile. i want to make a script for calculate time by time2 - time1 1600266278|random|1|2014-09-19 02:08:56.024|2014-09-19 02:08:59.398|A|B|ROOM|Num0208559970111101788|1|dog|dos 1600266200|random|4|2014-09-19 02:08:06.572|2014-09-19... (2 Replies)
Discussion started by: ooilinlove
2 Replies

3. Shell Programming and Scripting

Check time stamp formate in file

I have to check whether last line of the file has time stamp or not. File.txt cong = 0 This formats a date and time into the given strftime() format = 09 Dates can be passed to Smarty as unix timestamps = 56789 mysql timestamps or any string made up =98 Since Smarty-2.6.10 numeric... (4 Replies)
Discussion started by: Roozo
4 Replies

4. Shell Programming and Scripting

Deleting line with range check in awk

Consider a input.txt as: country=india ram ajit sham vijay //need to be removed country=india suman tharan raju what i did is: awk '$0~pat {n=NR+4} NR!=n' pat='country=india' input.txt > output.txt My looking to the above code is between any two country=india ,... (8 Replies)
Discussion started by: Gautham
8 Replies

5. Shell Programming and Scripting

Check file time stamp

Hi, I need help to read file in a directory on basis of time stamp. e.g. If file access in last 2 minutes it should not be copy to remote directory. Below is my script. #!/bin/ksh DATE=`date +"%Y-%m-%d_%H%M"` SEPARATER=" " exec < out_interfaces.cfg while read source_path... (10 Replies)
Discussion started by: qamar.alam
10 Replies

6. Solaris

System time and Cron time stamp not matching

On Solaris 10 server the system date won't match with the timestamp on files created by a cron jobs, Please help here is what i get when i check for system date infodba-ie10ux014:/tcpdv1_ie10/tcadmin/bin\n\r-> date Tue Apr 24 15:27:43 GMT 2012at same time i executed a cron job, and checked... (4 Replies)
Discussion started by: karghum
4 Replies

7. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

8. Shell Programming and Scripting

Date and time range extraction via Awk or analysis script?

Hello does anyone know of an awk that will extract log file entries between a specific date and time range, eg: awk '/15\/Dec\/2010:16:10:00/, /15\/Dec\/2010:16:15:00/' access_log but one that works? Or a free command line log file analysis tool/script? I'd like to be able to view... (2 Replies)
Discussion started by: competitions
2 Replies

9. Shell Programming and Scripting

time stamp perl script error out of range 1..31

Hi, while running the perl script i am getting this error message , Day '' out of range 1..31 at rsty.sh line 44 what do iam missing in the script, any suggestion #!/usr/bin/perl use Time::Local; my $wday = $ARGV; my $month = $ARGV; # convert the month shortname into 0-11 number if... (4 Replies)
Discussion started by: saha
4 Replies

10. Shell Programming and Scripting

awk to print files in a dir between the given time stamp

hi all, i want to print all the files in a directory. between a time stamp like $8>=07:00 and $8<=09:00. please give me commands not only in awk by any other commands also. Thanks. (3 Replies)
Discussion started by: Arunprasad
3 Replies
Login or Register to Ask a Question