Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-24-2005, 10:47 AM
|
#1
|
Member
Registered: Nov 2003
Posts: 86
Rep:
|
archives, file timestamps and touch
I have a website and I want to modify some page elements but then restore the last modified time to what it was before I updated the file.
At the bottom of my pages I use php to read the last modified time of the document and print it to the page.
I have articles and other stuff that I do not want the time stamp to change, but I need to tweak the contents of the <head>. So nothing on the page is changing, just some meta tags.
The closest way I have found to do this would be to tar the whole site, make my changes, then read the time stamps from the files in the tar file, then use touch -mt to change the time stamps back.
How do I get the last modified timestamps from with in the tar file?
And can I have the timestamps outputted to a file with the time-stamp and the path?
Then How do I pipe that info to touch?
Is this possible?
What a headache, I'm going to do this kind of stuff with includes from now on so I don't need to worry about this again.
Any help would be appreciated.
|
|
|
02-24-2005, 02:38 PM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Before you mod things:
Code:
find -printf "%p %CY%Cm%Cd%CH%CM.%CS\n" > times.txt
Afterwards:
Code:
cat times.txt|while read file stamp; do touch -m -t$stamp $file; done
Cheers,
Tink
|
|
|
02-24-2005, 10:34 PM
|
#3
|
Member
Registered: Nov 2003
Posts: 86
Original Poster
Rep:
|
Thanks,
I asked a different way a few weeks ago, and got no help. Ill try it.
Thanks again
-Jacob
|
|
|
02-24-2005, 10:56 PM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Quote:
Originally posted by digitalgravy
Thanks,
I asked a different way a few weeks ago, and got no help. Ill try it.
Thanks again
-Jacob
|
I know ;)
I remembered it, and first checked what the responses
from the last thread were!
Hih.
Cheers,
Tink
|
|
|
02-28-2005, 01:44 PM
|
#5
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Quote:
Originally posted by digitalgravy
Thanks,
I asked a different way a few weeks ago, and got no help. Ill try it.
Thanks again
-Jacob
|
And? Did it work? :)
Cheers,
Tink
|
|
|
03-01-2005, 10:27 AM
|
#6
|
Member
Registered: Nov 2003
Posts: 86
Original Poster
Rep:
|
It works!
That is exactly what I was looking for.
Thanks Again!
|
|
|
02-08-2006, 08:47 PM
|
#7
|
Member
Registered: Nov 2003
Posts: 86
Original Poster
Rep:
|
It's been awhile
Quote:
Originally Posted by Tinkster
Before you mod things:
Code:
find -printf "%p %CY%Cm%Cd%CH%CM.%CS\n" > times.txt
Afterwards:
Code:
cat times.txt|while read file stamp; do touch -m -t$stamp $file; done
Cheers,
Tink
|
I had been getting mixed results with this. Some of the times were showing up incorrect. I use this technique once in a while. Well what is happening is the original command specified %C which returns the last Status Change. I need it to show the last modification time. For this you use %T.
Code:
find -printf "%p %TY%Tm%Td%TH%TM.%TS\n" > times.txt
This returns exactly what I want.
Thanks Tinkster, you got me in the right direction!
|
|
|
All times are GMT -5. The time now is 03:23 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|