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.
Date display from ls -l command
Name: Carl Hoog Date: July 14, 2003 at 08:02:04 Pacific OS: HP-UX CPU/Ram: Not relevent
Comment:
When doing a ls -l command, the date for recently modified files appears as, for example, Jul 9 17:03. For much older files, it appears as, for example, Feb 7 2002. Does anyone know what controls this and can it be manipulated in a given session so that all appear as MMM DD YYYY or some other selectable format the includes the year? I want to do a ls -lt and capture the date stamp of the oldest file into a shell variable. I need it to always be in the same format and to include the year.
"If the time of last modification is greater than six months ago, it is shown in the format 'month date year' for the POSIX locale. When the LC_TIME locale category is not set to the POSIX locale, a different format of the time field may be used. Files modified within six months show 'month date time'."
Unfortunately I don't see any options or settings for changing this behaviour. Looks like an interesting scripting project...
0
Response Number 2
Name: nails Date: July 14, 2003 at 10:54:30 Pacific
Reply:
Hi:
William is right about the 6-months time thing. I've used this code snippet, but it probably has a problem from Jan thru June, but it's a start:
year=$(date +%Y)
ls -l | nawk -v year=${year} ' { printf("%s\n", index($(NF-1), ":") ? year : $(NF-1)); }
Summary: I want to retrieve last modified date from a list of files with DD/MM/YY HH:MI display. A ls-l command retreives : Month DD HH:MI for recent files (< 6 months) Month DD year for older files What can i...
Summary: 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;N...
Summary: T.T. I'm assuming you want to copy files with a creation date of May 13. The 6th and 7th fields of the 'ls -l' command are the month and day: #!/bin/ksh ls -l |while read f1 f2 f3 f4 f5 f6 f7 f8 f9 d...