[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

date comarision script

Posted on 2002-07-04
5
Medium Priority
?
242 Views
Last Modified: 2013-12-27
i have a file like this

usera date of birth 10-July-00
userb date of birth 08-Sep-01
userc date of birth 15-Apr-02
userd date of birth 03-Jan-00
---
--
-- etc


i want to know all the users whose date of birth is before jan-02.

how can i find.?


msnr
0
Comment
Question by:msnr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
billwcc earned 400 total points
ID: 7129999
Hey,

You need 2 things here:

1.  4-digit years in your data file.

2.  Perl!

Assuming your data file is called "data", and you have added 4-digit years, try this:

#!/usr/bin/perl
open(FILE, "./data") ||
   die ("Unable to open data file.\n");

while ($line = <FILE>){
   chop ($line);
      @fields = split(/-/, $line);
      if($fields[2] < 2002) {
         print "$line\n";
      }
}

You can modify the above to use 2-digit years, but the logic in the "if" clause becomes more complicated.
0
 
LVL 1

Author Comment

by:msnr
ID: 7131470
my idea is not only year....with month....

for ex..... before 2002 july...


0
 
LVL 1

Expert Comment

by:billwcc
ID: 7131821
Man, you really need to get Perl into your life!

There are any number of ways to go about this type of sorting problem.  You could set a lookup table where you map the months to a numeric value and then compare based on that, or just do a compound comparison based on the months as text.

0
 
LVL 21

Expert Comment

by:tfewster
ID: 8003355
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by billwcc
 
Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8065837
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question