<div dir="ltr"><div>This is slightly more concise, but it seems to drop second fractions.  Something else to consider is the Access time.  Hopefully this is helpful.</div><div><br></div><div><br></div>EPOCH_MTIME=$(stat -c %Y $FILE)<br>
<div><span style="font-family:arial,sans-serif;font-size:13px">perl -pi -e 's/FOO/BAR/' "$FILE"</span><br></div><div><font face="arial, sans-serif">touch -d @$EPOCH_MTIME $FILE</font><br></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><br></font></div><div><div>Access: 2013-09-08 23:48:25.155170463 -0500</div><div>Modify: 2013-09-08 23:48:25.155170463 -0500</div><div>Change: 2013-09-08 23:48:25.155170463 -0500</div>
</div><div><br></div><div><div>Access: 2013-09-08 23:48:25.<span style="background-color:rgb(255,255,0)">000000000</span> -0500</div><div>Modify: 2013-09-08 23:48:25.<span style="background-color:rgb(255,255,0)">000000000</span> -0500</div>
<div>Change: 2013-09-09 00:39:02.306271692 -0500</div></div><div><br></div><div><br></div><div>-Gavin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 6, 2013 at 9:59 PM, Mike Miller <span dir="ltr"><<a href="mailto:mbmiller+l@gmail.com" target="_blank">mbmiller+l@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Changing the system clock is a very bad idea, but I guess you figured that out and sent the message anyway.  This means that you need a beer.<br>

<br>
I think the method I came up with is OK, but if there were a way to tell perl not to change the timestamp when the -i option is used, that would be better.  I guess this is telling me, but I don't understand it:<br>
<br>
<a href="http://www.velocityreviews.com/forums/t890336-preserve-timestamp.html" target="_blank">http://www.velocityreviews.<u></u>com/forums/t890336-preserve-<u></u>timestamp.html</a><br>
<br>
which leads me here:<br>
<br>
<a href="http://perldoc.perl.org/functions/utime.html" target="_blank">http://perldoc.perl.org/<u></u>functions/utime.html</a><br>
<br>
And I don't knoww what to do with that, so I might just stick to what I did last time.  ;-)<span class="HOEnZb"><font color="#888888"><br>
<br>
Mike</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Fri, 6 Sep 2013, Jeremy MountainJohnson wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In Python the os module should have something to modify it (one would<br>
think so since it can read this fs meta). If not, you could write a<br>
script to change the system clock to the original read time stamp of<br>
the file, modify the file, than change the clock back- would do the<br>
job of maintaining the modified attribute. Heh, probably not easier,<br>
but the best my work wired mind could come up with on a Friday :-)<br>
--<br>
Jeremy MountainJohnson<br>
<a href="mailto:Jeremy.MountainJohnson@gmail.com" target="_blank">Jeremy.MountainJohnson@gmail.<u></u>com</a><br>
<br>
<br>
On Fri, Sep 6, 2013 at 5:17 PM, Mike Miller <<a href="mailto:mbmiller%2Bl@gmail.com" target="_blank">mbmiller+l@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don't know the best way to do this.  I wanted to change some files but I<br>
wanted to keep the original timestamps.  So I did it this way:<br>
<br>
# get the timestamp<br>
TIME_STRING=$(date -d "$(stat -c %y FILE)" +"%Y%m%d%H%M.%S")<br>
<br>
make changes to FILE<br>
<br>
# change the timestamp back to what it was before the change<br>
touch -t $TIME_STRING FILE<br>
<br>
<br>
My use was something like this:<br>
<br>
for FILE in $(grep -l FOO) ; do<br>
   TIME_STRING=$(date -d "$(stat -c %y "$FILE")" +"%Y%m%d%H%M.%S")<br>
   perl -pi -e 's/FOO/BAR/' "$FILE"<br>
   touch -t $TIME_STRING "$FILE"<br>
done<br>
<br>
<br>
So how do you all do this kind of thing?<br>
<br>
Mike<br>
______________________________<u></u>_________________<br>
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota<br>
<a href="mailto:tclug-list@mn-linux.org" target="_blank">tclug-list@mn-linux.org</a><br>
<a href="http://mailman.mn-linux.org/mailman/listinfo/tclug-list" target="_blank">http://mailman.mn-linux.org/<u></u>mailman/listinfo/tclug-list</a><br>
</blockquote>
______________________________<u></u>_________________<br>
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota<br>
<a href="mailto:tclug-list@mn-linux.org" target="_blank">tclug-list@mn-linux.org</a><br>
<a href="http://mailman.mn-linux.org/mailman/listinfo/tclug-list" target="_blank">http://mailman.mn-linux.org/<u></u>mailman/listinfo/tclug-list</a><br>
<br>
</blockquote>
______________________________<u></u>_________________<br>
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota<br>
<a href="mailto:tclug-list@mn-linux.org" target="_blank">tclug-list@mn-linux.org</a><br>
<a href="http://mailman.mn-linux.org/mailman/listinfo/tclug-list" target="_blank">http://mailman.mn-linux.org/<u></u>mailman/listinfo/tclug-list</a><br>
</div></div></blockquote></div><br></div>