The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with subtracting time stamps in excel.. ks_reddy UNIX for Dummies Questions & Answers 1 04-15-2009 03:30 PM
Adding Date & time stamps to filename manish.s UNIX for Dummies Questions & Answers 1 03-13-2009 04:00 AM
pERL SCRIPT FOR MONITORING DATE/TIME STAMPS FOR START AND STOP OF APPLICAION IN A LOG FREDDIE091970 Shell Programming and Scripting 4 03-31-2008 10:59 PM
List files with date and time stamps only davewg UNIX for Dummies Questions & Answers 2 01-14-2008 06:33 AM
Copying Files in the same order along with time stamps shyam.appalla Shell Programming and Scripting 2 12-04-2005 10:44 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-21-2009
RSC1985 RSC1985 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 25
comparing time stamps

Hello All,

I'm generating timestamps (file creation timestamps) for all the files in a directory. I need to compare all the timestamps.
for example if i have 4 files and their timestamps are 20091125114556,
20091125114556,20091125114556,20091125114556 respectively.

I need to differentiate atleast secs portion to recognize the file. So what i'm going to do is if all timestamps are same then i will modify seconds portion. But my question here is how to compare these timestamps respect to their corresponding files.?

Please suggest a way but not the solution.

Thanks in advance,
RSC1985
  #2 (permalink)  
Old 07-21-2009
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
you are comparing with what?

where the timestamps present? in the filename ?
  #3 (permalink)  
Old 07-21-2009
RSC1985 RSC1985 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 25
Comparing with the other timestamps of other files. And i'm storing timeStamp in a variable as of now. My questions is how to acheive that comparison task?
  #4 (permalink)  
Old 07-21-2009
rakeshawasthi rakeshawasthi is offline
Registered User
  
 

Join Date: Aug 2004
Location: India
Posts: 379
Search a bit, this has been answered before.
I will give you a hint how you can do this:
1. separte the YYYYMMDD and HHMISS parts
2. Compare the YYYYMMDD if they are same
3. compare HHMISS
this way you can know whether the timestamps are same or not... rest is just the coding manipulation.
  #5 (permalink)  
Old 07-22-2009
RSC1985 RSC1985 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 25
Can't I do direct comparison Because if i store into a variable the timestamp, I can directly do the comparison. But I'm struggling to store all these timestamps and next comparing all these timestamps one with the other.I should get how many are same and what are those so that i can go with my rest of the processing.If could give some more idea on this it would be really helpful.
  #6 (permalink)  
Old 07-22-2009
ryandegreat25 ryandegreat25 is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 236
can you post specific samples so we understand the problem better?
  #7 (permalink)  
Old 07-22-2009
RSC1985 RSC1985 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 25
Below is the example.

I will get the timestamps(file modification time in the form YYYYMMDDHHMMSS) for all the files in the directory by the below code.


for filename in `find . -type f -exec basename {} \;`
do
echo "The file name is $filename"
timestamp=`../../tmp/getTime.pl $filename`
echo "the timestamp of $filename is $timestamp"
done

Now I have to check for what are the files that have same timestamps.
for example file1 has 20091225114556 timestamp and file3 has 20091225114556 timestamp and file4 has also 20091225114556 the same timestamp. My task is to modify these timestamps inorder to make them unique.
So i need to modify the timestamp of file3 and file4 as 20091225114557 and 20091225114558.

could you please give an idea how to proceed on this?
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0