Comparing date values stored in a file

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Comparing date values stored in a file
# 1  
Old 05-12-2010
Question Comparing date values stored in a file

Hi all,
I have written a script which stores data along with requisite dates in a file.
I need to compare the stored date values in the file to obtain the row with the highest date value i.e. the recent most entered record in the file.
Please help cause i dont know how we can compare dates in such case.
# 2  
Old 05-12-2010
Can you provide a sample of the file? What is the format of each line and the date stamp.

Does the data already exist or are you also trying to define the data format?
# 3  
Old 05-27-2010
After retrieving you values from the file. You can compare the date values with something like this:
Code:
 compvalue=`date -s "2010/05/05" +%s`

That will convert it to seconds. The highest value wins! Smilie
# 4  
Old 06-02-2010
date "+%M%S" - only print minutes and seconds seconds. {the highest the value ) if only seconds doesnt solves ur purpose..
# 5  
Old 06-04-2010
Check posting #2 Smilie
# 6  
Old 06-09-2010
sumi_mn, I think till you provide the sample data, a concrete solution cannot be given.
# 7  
Old 06-12-2010
A sample output is a must ...

Still why don't you use awk and take the $n value to compare between the two files .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Applying sed against a file from a list of values stored in a variable

Hi Forum. I have the following challenge at work that I need to write a script for. I have a file abc.txt with the following contents: 4560123456 4570987654 4580654321 I want to be able to search/replace in abc.txt - the first 4 characters anything starting with 4560 to 7777; 4570... (3 Replies)
Discussion started by: pchang
3 Replies

2. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date #!/usr/bin/ksh set -x for s in server ; do ssh -T $s <<-EOF from_date="12-Jan-2015 12:02:09" to_date="24-Jan-2015 13:02:09" echo \$from_date echo... (7 Replies)
Discussion started by: raj48
7 Replies

3. Shell Programming and Scripting

Awk: Comparing arguments with in line values of file and printing the result

I need to develop a script where I will take two date arguments as parameter date1 and date2 which will in format YYYYMM. Below is the input file say sample.txt. sample.txt will have certain blocks starting with P1. Each block will have a value 118,1:TIMESTAMP. I need to compare the... (7 Replies)
Discussion started by: garvit184
7 Replies

4. Shell Programming and Scripting

Reading and Comparing values of file

Hi gurus.. Am reading a file, counting number of lines and storing it in a variable. Then am passing that variable into If loop for comparision, if the number of lines are greater than 1000 it should split a file if not it should send the file name to archive folder.. but when i execute the... (4 Replies)
Discussion started by: azherkn3
4 Replies

5. Red Hat

How to check values stored in variable?

hey, i have stored values of query like this val_2=$( sqlplus -s rte/rted1@rel75d1 << EOF set heading off select source_id from cvt_istats where istat_id > $val_1; exit EOF ) echo $val_2 now , val_2 has five values displayed like this 1 2 3 4 5 what i have to do is to check the... (1 Reply)
Discussion started by: ramsavi
1 Replies

6. 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

7. 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

8. Programming

to compare two integer values stored in char pointers

How can I compare two integer values which is stored in char pointers? suppose I have char *a and char *b having values 10 and 20. how can i find the shorter value? (1 Reply)
Discussion started by: naan
1 Replies

9. 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

10. Shell Programming and Scripting

Comparing data in file with values in table

Hi, I want to calculate the number of pipe delimiters in a file for all lines seperately. For eg:i have a file Project.txt Mohit|chawla|123|678 File1|File2|345|767|678 And my file contains many lines like this it shd give me the output as 4 5 or give me the output for all the... (0 Replies)
Discussion started by: Mohit623
0 Replies
Login or Register to Ask a Question