Operating System - HP-UX
1833776 Members
2294 Online
110063 Solutions
New Discussion

Re: find date including year of file modification

 
SOLVED
Go to solution
Nigel McGuinness_1
Occasional Advisor

find date including year of file modification


Can anyone tell me if it is possible to get the year included in the date of last modification for a file.
5 REPLIES 5
Peter Kloetgen
Esteemed Contributor

Re: find date including year of file modification

Hi Nigel,

yep.... it is possible. You need two commands to get what you want:

man touch

--> use the touch command to create a reference file. You can give a time stamp to your file when you generate it.

touch time_stamp file_name

man find

have a look to the -newer option. You can also do a logical combination of dates to get, if needed, use the -a option.

find /start_point -newer reference_file -exec ls -al {} \;

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Michael Tully
Honored Contributor

Re: find date including year of file modification

Hi,

There are two ways:

One install 'super ls' you can get it from here:

http://gatekeep.cs.utah.edu/hppd/hpux/Shells/sls-1.0/

or another suggested example that I've kept.

$ ll /usr/conf/lib/libspt.a
-r--r--r-- 1 bin bin 63556 Oct 30 1997 /usr/conf/lib/libspt.a
$ echo /usr/conf/lib/libspt.a | cpio -o 2>/dev/null | cpio -ivt 2>/dev/null
100444 bin 63556 Oct 30 23:50:34 1997 /usr/conf/lib/libspt.a

There are aslo some further examples here:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xeb38c4c76f92d611abdb0090277a778c,00.html

HTH
Michael
Anyone for a Mutiny ?
Olav Baadsvik
Esteemed Contributor

Re: find date including year of file modification


Hi,I assume you are talking about the output of the ls command.

The man-page says:

If the time of last modification is greater
than six months ago, or any time in the future, the year is
substituted for the hour and minute of the modification
time.


If you write your own little c-program you can use the stat() function
to get the info as creation- modification- and access-time info all
are available as time_t info.

Regards
Olav

H.Merijn Brand (procura
Honored Contributor
Solution

Re: find date including year of file modification

Attached is the C source of what I wrote as 'lsi'
Enjoy, Have FUN! H.Merijn
Robin Wakefield
Honored Contributor

Re: find date including year of file modification

Hi Nigel,

Some perl to give you the full modification time:

perl -e '{print scalar localtime((stat(shift))[9]),"\n"}' filename

Rgds, Robin