Change a file's timestamp | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

Change a file's timestamp

AIX


Tags
aix, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-13-2008
shibajighosh shibajighosh is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 2 March 2010, 4:03 AM EST
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Change a file's timestamp

Hi,

I want to modify a file and then change the file's timestamp back to what it was before the modification. It should look as if the file has'nt been modifed. The entire operation needs to be done inside a ksh script. Can anyone suggest how I can trap a file's stamp in a variable within a shell.

Thanks in advance.
Sponsored Links
    #2  
Old 05-13-2008
penchal_boddu penchal_boddu is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 11 February 2013, 3:10 PM EST
Location: Bangalore
Posts: 173
Thanks: 0
Thanked 5 Times in 4 Posts
Hi,

Try touch command

if files present time stamp is may 10 10:24

Modify ur file, then give the following command

touch -t 200805101024 filename

Decomposition of 200805101024
2008 year , 05 - month number , date, time


Thanks
Penchal
The Following 2 Users Say Thank You to penchal_boddu For This Useful Post:
Bill L. (04-04-2011), kah00na (10-05-2012)
Sponsored Links
    #3  
Old 05-13-2008
shibajighosh shibajighosh is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 2 March 2010, 4:03 AM EST
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Thanks for the response. I used touch -t several times. What I wanted to know is, how to trap the timestamp of the file within a shell in a format which can be fed to "touch" command. I want to get the file's timestamp in YYYYMMDDHHMI format.

Thanks in advance.
    #4  
Old 05-13-2008
penchal_boddu penchal_boddu is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 11 February 2013, 3:10 PM EST
Location: Bangalore
Posts: 173
Thanks: 0
Thanked 5 Times in 4 Posts
ls -ltr filename
_rw_rw_rw_ 1 penchal grp 1024 May 13 18:08 filename


Ur timestamp becomes : 200805131808
Sponsored Links
    #5  
Old 05-27-2008
rcarnesiii rcarnesiii is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 3 March 2014, 2:09 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Sounds like someone is trying to do something fishy "file should appear as if it has not been modified" . Anyways, I have a question about the modification time for a symbolic link.

foo.c -> apps/gendev/src/foo.c

the timestamp on apps/gendev/src/foo.c is say 'May 27 11:37'

the timestamp on foo.c (which points to the source file) is 'May 27 10:42' which is when the link was created. Everytime I edit foo.c from my directory the timestamp on apps/gendev/src/foo.c is updated which I understand because I am really modifying that file. I want to know if there is a way to modify the timestamp on the link without relinking the file?

Thanks
Sponsored Links
    #6  
Old 05-27-2008
Franklin52's Avatar
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 21 August 2014, 2:35 PM EDT
Location: The Netherlands
Posts: 7,703
Thanks: 121
Thanked 532 Times in 503 Posts
rcarnesiii.

Please don't hijack another ones thread but open a new thread for your question.

Thanks.
Sponsored Links
    #7  
Old 05-27-2008
Dave Miller's Avatar
Dave Miller Dave Miller is offline
Registered User
 
Join Date: Dec 2007
Last Activity: 5 October 2010, 9:10 AM EDT
Location: Northern NJ, USA
Posts: 151
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by penchal_boddu View Post
ls -ltr filename
_rw_rw_rw_ 1 penchal grp 1024 May 13 18:08 filename


Ur timestamp becomes : 200805131808
FYI: The time is only shown if the timestamp is less than 6 months old. If it's more than 6 months, the ls command shows the year instead of time.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to compare a file by its timestamp and store in a different location whenever timestamp changes? mailsara UNIX for Dummies Questions & Answers 2 07-25-2011 03:48 PM
Change File Header Timestamp mudi Shell Programming and Scripting 5 12-07-2008 11:27 PM
move file change timestamp tekster757 UNIX for Dummies Questions & Answers 2 08-10-2007 01:01 PM
change timestamp of file isingh786 HP-UX 1 05-15-2006 01:56 PM
Timestamp of File permission change jyotipg UNIX for Advanced & Expert Users 1 02-19-2003 02:02 AM



All times are GMT -4. The time now is 07:55 PM.