Sponsored Content
Full Discussion: Date Compare
Top Forums UNIX for Dummies Questions & Answers Date Compare Post 72940 by zazzybob on Wednesday 25th of May 2005 09:05:54 PM
Old 05-25-2005
Please copy and paste code *directly* from your scripts, as looking at your code above, there are several syntax errors that would prevent the script from running at all...

e.g.
Code:
$a = `echo ls -l | cut 44-52`

There are FOUR things wrong with this one statement alone.

1. $a - do not preceed assignments with $
2. no spaces around the = allowed in assignments!
3. echo ls -l is just going to echo ls -l!
4. cut 44-52 (cut what? fields, chars, bytes, ???)

If this *really* was your script, it'd fall over straight away....

Cheers
ZB
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare today's date with date in a file

Hi I am very new to scripting, Can someone show me how to (in unix shell script) compare the system's date with a date in a file. The requirement is to somehow open this file (which will only have a date in it) and compare it with today's date. If they are equal execute a procedure below but if... (4 Replies)
Discussion started by: siog
4 Replies

2. Shell Programming and Scripting

Compare date from db2 table to yesterday's Unix system date

I am currently running the following Korn shell script which works fine: #!/usr/bin/ksh count=`db2 -x "select count(*) from schema.tablename"` echo "count" I would like to add a "where" clause to the 2nd line that would allow me to get a record count of all the records from schema.tablename... (9 Replies)
Discussion started by: sasaliasim
9 Replies

3. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

4. Shell Programming and Scripting

Adding days to system date then compare to a date

Hi! I am trying to read a file and every line has a specific date as one of its fields. I want to take that date and compare it to the date today plus 6 days. while read line do date=substr($line, $datepos, 8) #date is expected to be YYYYMMDD if ; then ...proceed commands ... (1 Reply)
Discussion started by: kokoro
1 Replies

5. Shell Programming and Scripting

Compare Date with String in date format

Hi, I am new to this forum, searched, but for some reason did not find much help, so a new thread. I am trying to compare date with a string which is in date format , but for some reason, system does not give me the right result. Date is coming in a file and i am comparing the same with... (2 Replies)
Discussion started by: mkstool
2 Replies

6. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

7. Shell Programming and Scripting

Compare the system date with date from a text file

I get the date that's inside a text file and assigned it to a variable. When I grep the date from the file, I get this, Not After : Jul 28 14:09:57 2017 GMT So I only crop out the date, with this command echo $dateFile | cut -d ':' -f 2,4The result would be Jul 28 14:57 2017 GMT How do I... (3 Replies)
Discussion started by: Loc
3 Replies

8. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

9. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies

10. UNIX for Beginners Questions & Answers

Compare Date to today's date in shell script

Hi Community! Following on from this code in another thread: #!/bin/bash file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'` file_date=`/bin/date -d "$file_string"` file_epoch=`/bin/date -d "$file_string" +%s` now_epoch=`/bin/date +%s` if then #let... (2 Replies)
Discussion started by: Greenage
2 Replies
Data::Compare::Plugins(3pm)				User Contributed Perl Documentation			       Data::Compare::Plugins(3pm)

NAME
Data::Compare::Plugins - how to extend Data::Compare DESCRIPTION
Data::Compare natively handles several built-in data types - scalars, references to scalars, references to arrays, references to hashes, references to subroutines, compiled regular expressions, and globs. For objects, it tries to Do The Right Thing and compares the underlying data type. However, this is not always what you want. This is especially true if you have complex objects which overload stringification and/or numification. Hence we allow for plugins. FINDING PLUGINS
Data::Compare will try to load any module installed on your system under the various @INC/Data/Compare/Plugins/ directories. If there is a problem loading any of them, an appropriate warning will be issued. Because of how we find plugins, no plugins are available when running in "taint" mode. WRITING PLUGINS
Internally, plugins are "require"d into Data::Compare. This means that they need to evaluate to true. We make use of that true value. Where normally you just put: 1; at the end of an included file, you should instead ensure that you return a reference to an array. This is treated as being true so satisfies perl, and is a damned sight more useful. Inside that array should be either a description of what this plugin is to do, or references to several arrays containing such descriptions. A description consists of two or three items. First a string telling us what the first data-type handled by your plugin is. Second, (and optional, defaulting to the same as the first) the second data-type to compare. To handle comparisons to ordinary scalars, give the empty string for the data-type, ie: ['MyType', '', sub { ...}] Third and last, we need a reference to the subroutine which does the comparison. That subroutine should expect to take two parameters, which will be of the specified type. It should return 1 if they compare the same, or 0 if they compare different. Be aware that while you might give a description like: ['Type1', 'Type2', sub { ... }] this will handle both comparing Type1 to Type2, and comparing Type2 to Type1. ie, comparison is commutative. If you want to use Data::Compare's own comparison function from within your handler (to, for example, compare a data structure that you have stored somewhere in your object) then you will need to call it as Data::Compare::Compare. However, you must be careful to avoid infinite recursion by calling D::C::Compare which in turn calls back to your handler. The name of your plugins does not matter, only that it lives in one of those directories. Of course, giving it a sensible name means that the usual installation mechanisms will put it in the right place, and meaningful names will make it easier to debug your code. For an example, look at the plugin that handles Scalar::Properties objects, which is distributed with Data::Compare. DISTRIBUTION
Provided that the above rules are followed I see no reason for you to not upload your plugin to the CPAN yourself. You will need to make Data::Compare a pre-requisite, so that the CPAN.pm installer does the right thing. Alternatively, if you would prefer me to roll your plugin in with the Data::Compare distribution, I'd be happy to do so provided that the code is clear and well-commented, and that you include tests and documentation. SEE ALSO
Data::Compare Data::Compare::Plugins::Scalar::Properties AUTHOR
Copyright (c) 2004 David Cantrell <david@cantrell.org.uk>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2009-03-07 Data::Compare::Plugins(3pm)
All times are GMT -4. The time now is 03:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy