|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Amend File Without Changing Timestamp
Hi,
Is it possible to amend a file without changing the last modified date? If it is, how do you do it? If it's not, is there a way to create an empty file with the same timestamp as another file? I know you can use touch -t yyyymmddhhmm.ss filename but, I would want the file to have the exact same timestamp as another file. Any help would be greatly appreciated. Thanks ****EDIT**** Sorry, I forgot to mention. I'm trying to script using bash. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
You will use touch option -r (reference file) with will create a file with exact same timestamp as file you referenced to.
Check man touch |
| The Following User Says Thank You to Peasant For This Useful Post: | ||
Ste_Moore01 (12-04-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks very much, Peasant.
I looked through the man page for touch and must've missed it. Thanks! |
|
#4
|
|||
|
|||
|
Actually: Code:
touch -r file1 file2... will set the access time and the modification time of file2 and any other file operands to match the access time and the modification time of file1. If you just want to reset the modification time, use: Code:
touch -m -r file1 file2... |
| The Following User Says Thank You to Don Cragun For This Useful Post: | ||
Ste_Moore01 (12-04-2012) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks Don.
I realised what Peasant meant with his post and it worked perfectly. Thanks for the info on touch -m though. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| 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 |
| Getting a relative timestamp from timestamp stored in a file | vaibhavkorde | Shell Programming and Scripting | 1 | 04-27-2011 06:08 AM |
| Changing timestamp file in crontab | Zak | UNIX for Advanced & Expert Users | 4 | 04-30-2009 09:27 PM |
| Amend Unix hostname | venhart | UNIX for Advanced & Expert Users | 3 | 03-11-2009 03:45 PM |
| changing timestamp of a file | krishan | Solaris | 1 | 05-23-2005 10:50 AM |
|
|