Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Display file date as a 3 digit day
Name: richaja Date: December 3, 2004 at 12:27:06 Pacific OS: HP-UX CPU/Ram: n/a
Comment:
Is there a way to format a date (i.e. Dec 2) to a 3 digit day of the year?
For example, I have a file with a timestamp of "Dec 2 08:42" (when I do a "ls -l"). I need a way to convert that date to it's 3 digit day of the year value (which is 337). Is there a Unix function that will do that for me?
Name: David Perry Date: December 3, 2004 at 13:04:47 Pacific
Reply:
It is called a julian date. Reference your man pages to confirm this works.
date +%j
0
Response Number 2
Name: richaja Date: December 3, 2004 at 13:19:28 Pacific
Reply:
date +%j That returns today's Julian date, but I need to be able to convert the date from a file's timestamp to a Julian date. The timestamp of the file could be a date from 3 months ago.
Is there a function that I can pass a date to, that will format it to a Julian date?
Thanks, Joe
0
Response Number 3
Name: nails Date: December 4, 2004 at 15:47:39 Pacific
Name: Wolfbone Date: December 5, 2004 at 08:35:49 Pacific
Reply:
Given a date in the form: m=Dec; y=2004; d=5, extracted from ls -l
set -A month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan=31;Feb=28;Mar=31;Apr=30;May=31;Jun=30;Jul=31;Aug=31;Sep=30;Oct=31;Nov=30;Dec=31 (((y/4)*4==y))&&Feb=29;(((y/100)*100==y && (y/400)*400!=y))&&Feb=28 i=0; while [[ ${month[i]} != $m ]]; do eval "k=\$${month[i]}" ((j+=k));((i++)) done ((j+=d));typeset -Z3 j; print $j
You just need to check for when ls -l gives the time instead of the year and replace it with the current year.
0
Response Number 5
Name: Wolfbone Date: December 6, 2004 at 02:53:44 Pacific
Reply:
Hmm... Seems I was unaware of the % operator when I wrote that originally. Replace the 3rd line with:
Summary: Hi all, I'm v new to UNIX scripting and am having a particularly annoying problem. I have a script which launches SQLPLUS and calls a .sql file passing a parameter. The mechanism all works fine excep...
Summary: Hello! I'm wondering if some one could help me with the following with a UNIX shell scripting. a) I want to count the files according to the date. Please find the details as follows, Oct 15, ...
Summary: Hi, in order to compare date file with the current date, i use this find [path] -daystart -[a/c/m]time [+/-]n -atime n File was last accessed n*24 hours ago. -ctime n File's status was last changed n...