Getting a file julian date
|
Original Message
|
Name: kayarsenal
Date: August 25, 2006 at 01:13:16 Pacific
Subject: Getting a file julian dateOS: XPCPU/Ram: Intel/1GBModel/Manufacturer: HP |
Comment: Hi All, Is it possible to get teh julian date a file was created(modified) ? For example, I could get the julian date of today by date +%j which gives 237.The last day of the year is 365. I want to specify a condition in a script, if the sysdate(julian) minus julian date of FOLDER>14, then do something... How do I do this? Thanks a lot Kayzone
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: kayarsenal
Date: August 25, 2006 at 01:15:03 Pacific
|
Reply: (edit)In short,I just want to check if the difference between present date and the date of file creation is greater than 14.Any other approach is welcome. Thanks Kayzone
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: nails
Date: August 25, 2006 at 09:07:41 Pacific
|
Reply: (edit)Have you thought about creating a file with a mod time of 14 days ago: # file created for Aug 8 touch -t 200608110000 /tmp/myfile # and then use find's newer option: find . -type f -newer /tmp/myfile -print
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: James Boothe
Date: August 25, 2006 at 11:47:56 Pacific
|
Reply: (edit)The -newer solution requires you to specify the 2-weeks-old date, which of course will change daily. Just use -mtime for finding files either older than or less than 14 days of age: find . -type f -mtime -14 find . -type f +mtime +14
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: lchi2000g
Date: August 26, 2006 at 12:54:45 Pacific
|
Reply: (edit)The command: expr $(date +%s) - $(date +%s -r file.txt) gives you the difference in seconds between the current time and last modification time of file.txt file %s seconds since `00:00:00 1970-01-01 UTC' (a GNU extension) Example script: #!/bin/ksh FILE=file.txt if [ `expr $(date +%s) - $(date +%s -r $FILE)` -gt 1209600 ]; then echo "Last modification time of $FILE is more than 14 days ago" else echo "Last modification time of $FILE is less than 14 days ago" fi Luke Chi
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: