Operating System - HP-UX
1753777 Members
7760 Online
108799 Solutions
New Discussion юеВ

Can I change the update/modify time of a file??

 
Kenneth Leung_2
Frequent Advisor

Can I change the update/modify time of a file??

Is there any way to modify the update/modify time of a file on HPUX?? Pls help. Thanks a lot.
12 REPLIES 12
RAC_1
Honored Contributor

Re: Can I change the update/modify time of a file??

You can. Read the man page of touch command.
man touch.

Why you want to do it?
There is no substitute to HARDWORK
Senthil Kumar .A_1
Honored Contributor

Re: Can I change the update/modify time of a file??

Hi Kenneth,

You can you "touch" command,using which you can modify the "modified time" or "access time" of a file.

For more details refer to man page of "touch" command.

man touch


Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Kenneth Leung_2
Frequent Advisor

Re: Can I change the update/modify time of a file??

thanks a lot for the help

In fact, I accidentally deleted an critical file. I recovered it from my archive & want to change the modified date to hide my fault....
RAC_1
Honored Contributor

Re: Can I change the update/modify time of a file??

Hiding the fault may not help. It may happen that program/app is looking for certain file ad may complain if it does'nt find it.
There is no substitute to HARDWORK
Senthil Kumar .A_1
Honored Contributor

Re: Can I change the update/modify time of a file??

Hey Kenneth,

You remind me of my little brother who tries to hide his fault. Anyway cute..

I wish you succeed in hiding yours :)

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
rariasn
Honored Contributor

Re: Can I change the update/modify time of a file??

Hi,

?date
Tue May 2 13:03:40 METDST 2006

?touch -t 05020200 prueba

?ll prueba
-rw-r----- 1 usr grp0 May 2 02:00 prueba

? man touch

ran
Geoff Wild
Honored Contributor

Re: Can I change the update/modify time of a file??

Off topic but, you shouldn't hide your fault - things happen - we all make mistakes. Best to learn from them and put processes in place to help prevent mistakes from happening again.

For rm, maybe alias it in /etc/profile:

alias rm='rm -i'

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Asif Sharif
Honored Contributor

Re: Can I change the update/modify time of a file??

The touch command changes certain dates for each file argument. By default, touch sets both the date of last file modification and the date of last file access to the current time.

-t time specifies a particular time using this format:

[[[[cc]yy]MM]dd]hhmm[.ss]

where cc is the optional first 2 digits of the year, yy is the optional last 2 digits of the year, MM is the optional number of the month (01-12), dd is the optional day of the month, hh is the hour in 24 hour format (required), mm is the minutes (required), ss is the optional seconds.

EXAMPLES
touch newfile

sets the modification time of newfile to the present.

touch -t 8001031305 oldfile

sets the modification time of oldfile to 13:05 on January 3, 1980.

touch -r oldfile newfile

sets the modification time of newfile to that of oldfile.

Regards,
Asif Sharif

Regards,
Asif Sharif
Kannan Varadachari
New Member

Re: Can I change the update/modify time of a file??

But it changes the create time to the current time, which I do not want. I would like to update the modify time to create time, keeping the create time the same.

dbracsora1:/tmp # ls -l tmpFileKernelParms.txt
-rw-r----- 1 oracle dba 11 Dec 31 1969 tmpFileKernelParms.txt
dbracsora1:/tmp # ls -lc tmpFileKernelParms.txt
-rw-r----- 1 oracle dba 11 Jun 3 07:09 tmpFileKernelParms.txt
dbracsora1:/tmp # touch -t 200606030710 tmpFileKernelParms.txt
dbracsora1:/tmp # ls -l tmpFileKernelParms.txt
-rw-r----- 1 oracle dba 11 Jun 3 07:10 tmpFileKernelParms.txt
dbracsora1:/tmp # ls -lc tmpFileKernelParms.txt
-rw-r----- 1 oracle dba 11 Jun 8 13:00 tmpFileKernelParms.txt
dbracsora1:/tmp #