1828162 Members
2176 Online
109975 Solutions
New Discussion

Re: unix file timestamp

 
SOLVED
Go to solution
Chris Baugh
Occasional Advisor

unix file timestamp

when listing a files details using ls -l, for example, the timestamp displayed depends on how old the file is (ie. if it's > 6 monthsd old, the year is displayed, without the time element).

Is there any way I can list the timestamp consistently, regardless of the age of the file. I want to retain the timestamp, to use in the 'touch' command later, to restamp the file modification time, after changing details within the file.
4 REPLIES 4
KapilRaj
Honored Contributor

Re: unix file timestamp

There is no direct way but you can have a look at my comments in the following thread which will do the job

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=548894

Regds,

Kaps
Nothing is impossible
Chris Baugh
Occasional Advisor

Re: unix file timestamp

Thanks for that. Only problem is that it doesn't go down to time level, which is really what I'm after. I guess this isn't possible for the files older than 6 months.
Bruno Ganino
Honored Contributor

Re: unix file timestamp

Read (options and Variables)
http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40G_HTML/MAN/MAN1/0202____.HTM
HTH
Bruno
Torino (Turin) +2H
Jdamian
Respected Contributor
Solution

Re: unix file timestamp

Have you tried the -r option of 'touch' command ?

For instance, you need to preserve the timestamp of 'myfile':

touch -r myfile myfile.ts

Then 'myfile.ts' is empty (presuming it didn't exist before) and its timestamp is one you need to preserve. Later, you must use 'myfile.ts' as timestamp source to other files:

touch -r myfile.ts yourfile