Sponsored Content
Top Forums Shell Programming and Scripting comparing variables to date as string Post 302599738 by guruprasadpr on Saturday 18th of February 2012 07:28:21 AM
Old 02-18-2012
Code:
$ awk -v dt=$mydate '$2 ~ dt{print $1}' myfile
A
E

Guru.
This User Gave Thanks to guruprasadpr For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

comparing variables

I have searched and found a few threads that have dealt with this, but the examples I've tried haven't seemed to help. I am monitoring our database log for high checkpoints. I can parse out the checkpoint value which can be anywhere from zero into a 3 digit number. I set a variable to be the... (3 Replies)
Discussion started by: MizzGail
3 Replies

2. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

3. Shell Programming and Scripting

Comparing two variables

Script #!/bin/sh hardware=PC os=WindowsNET for i in `cat newservers` do x=`sudo /opt/openv/netbackup/bin/admincmd/bpplclients |grep $i |head -40 |grep $i|awk '{print $3;exit}'` if then echo "$i is already added" else echo "Need to add" fi done O/p in debug mode bash-2.05$... (3 Replies)
Discussion started by: rajip23
3 Replies

4. UNIX for Dummies Questions & Answers

comparing 2 string variables in unix

search=Jul 22 date=Jul 22 if then echo They match >>this piece of code does not detect that search and date are equivalent strings.. what's wrong with it? (17 Replies)
Discussion started by: katdaniel16
17 Replies

5. Linux

Comparing the file drop date with todays date

Daily one file will dropped into this directory. Directory: /opt/app/jt/drop File name: XXXX_<timestamp>.dat.gz I need to write a script which checks whether the file is dropped daily or not. Any idea in the script how can we compare timestamp of the file to today's date?? (3 Replies)
Discussion started by: Rajneel
3 Replies

6. Shell Programming and Scripting

Comparing String with Number variables

I have two variables and want to perform some functions after comparison $cat file1 14.abcde a=`cut -f 1 -d "." file1 b=15 if then .... fi but i got an error message says that unary operator expected and i think its because of $a is a string and trying to compare with... (3 Replies)
Discussion started by: bonosungho
3 Replies

7. UNIX for Dummies Questions & Answers

comparing variables

im trying to compare ipaddresses. i loop through an array to see if the ip is already is in the array and if it is it should set a flag and then i wont add it to the array. but its just adding all the ipaddresses to the array if ] then ... (3 Replies)
Discussion started by: magnia
3 Replies

8. Shell Programming and Scripting

Need help in Shell Script comparing todays date with Yesterday date from Sysdate

Hi, I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing. The above requirement i want in Shell script(KSH)... Can any one please help me? Double post, continued here. (0 Replies)
Discussion started by: kumarmsk1331
0 Replies

9. UNIX for Dummies Questions & Answers

Comparing Output Date to Current System Date

Hi Guys, Anyone who knows how to compare the current date with the a file containing a date, say for example I have a file that looks like this: Command was launched from partition 0. ------------------------------------------------ Executing command in server server6 Fri Dec 16... (7 Replies)
Discussion started by: rymnd_12345
7 Replies

10. Shell Programming and Scripting

Comparing two variables

I have a script like this. Just couldn't get the comparison part work. Any thought? thanks, #!/usr/bin/ksh -x STEP=`echo $(basename $0 .ksh) | tr "" ""` log=/skip.log while read LINE do if then echo `date`: STEP $STEP skipped by user >> $log exit 0 fi done < $1 echo... (0 Replies)
Discussion started by: ghostmic
0 Replies
MooseX::Types::ISO8601(3pm)				User Contributed Perl Documentation			       MooseX::Types::ISO8601(3pm)

NAME
MooseX::Types::ISO8601 - ISO8601 date and duration string type constraints and coercions for Moose SYNOPSIS
use MooseX::Types::ISO8601 qw/ ISO8601TimeDurationStr /; has duration => ( isa => ISO8601TimeDurationStr, is => 'ro', coerce => 1, ); Class->new( duration => 60 ); # 60s => PT00H01M00S Class->new( duration => DateTime::Duration->new(%args) ) DESCRIPTION
This module packages several TypeConstraints with coercions for working with ISO8601 date strings and the DateTime suite of objects. DATE CONSTRAINTS
ISO8601DateStr An ISO8601 date string. E.g. "2009-06-11" ISO8601TimeStr An ISO8601 time string. E.g. "12:06:34Z" ISO8601DateTimeStr An ISO8601 combined datetime string. E.g. "2009-06-11T12:06:34Z" ISO8601DateTimeTZStr An ISO8601 combined datetime string with a fully specified timezone. E.g. "2009-06-11T12:06:34+00:00" COERCIONS The date types will coerce from: " Num " The number is treated as a time in seconds since the unix epoch " DateTime " The duration represented as a DateTime object. " Str " Non-expanded date and time string representations. e.g.:- 20120113 => 2012-01-13 170500Z => 17:05:00Z 20120113T170500Z => 2012-01-13T17:05:00Z Representations of UTC time zone (only an offset of zero is supported) e.g.:- 17:05:00+00:00 => 17:05:00Z 17:05:00+00 => 17:05:00Z 170500+0000 => 17:05:00Z 2012-01-13T17:05:00+00:00 => 2012-01-13T17:05:00Z 2012-01-13T17:05:00+00 => 2012-01-13T17:05:00Z 20120113T170500+0000 => 2012-01-13T17:05:00Z Also supports non-standards mixing of expanded and non-expanded representations e.g.:- 2012-01-13T170500Z => 2012-01-13T17:05:00Z 20120113T17:05:00Z => 2012-01-13T17:05:00Z DURATION CONSTRAINTS
ISO8601DateDurationStr An ISO8601 date duration string. E.g. "P01Y01M01D" ISO8601TimeDurationStr An ISO8601 time duration string. E.g. "PT01H01M01S" ISO8601DateTimeDurationStr An ISO8601 comboined date and time duration string. E.g. "P01Y01M01DT01H01M01S" COERCIONS The duration types will coerce from: " Num " The number is treated as a time in seconds " DateTime::Duration " The duration represented as a DateTime::Duration object. The duration types will coerce to: " Duration " A DateTime::Duration, i.e. the " Duration " constraint from MooseX::Types::DateTime. SEE ALSO
o MooseX::Types::DateTime o DateTime o DateTime::Duration o DateTime::Format::Duration VERSION CONTROL
http://github.com/bobtfish/moosex-types-iso8601/tree/master Patches are welcome. SEE ALSO
o http://en.wikipedia.org/wiki/ISO_8601 o http://dotat.at/tmp/ISO_8601-2004_E.pdf FEATURES
Fractional seconds If provided, the number of seconds in time types is represented to microsecond accuracy. A full stop character is used as the decimal seperator, which is allowed, but deprecated in preference to the comma character in ISO 8601:2004. BUGS
Probably full of them, patches are very welcome. Specifically missing features: o No timezone support - all times are assumed UTC o No week number type o "Basic format", which lacks seperator characters, is not supported for reading or writing. o Tests are rubbish. AUTHOR
Tomas Doran (t0m) "<bobtfish@bobtfish.net>" Dave Lambley "<davel@state51.co.uk>" The development of this code was sponsored by my employer <http://www.state51.co.uk>. Contributors Aaron Moses COPYRIGHT
Copyright (c) 2009 Tomas Doran. Some rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-05-11 MooseX::Types::ISO8601(3pm)
All times are GMT -4. The time now is 08:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy