Touch -d forms
Dazed_75
lthielster at gmail.com
Sat Mar 30 03:22:37 MST 2013
I keep losing the Internet connection here. But that solution worked like
a charm MM. Thanks again!
On Sat, Mar 30, 2013 at 1:54 AM, Dazed_75 <lthielster at gmail.com> wrote:
> Aaah, that looks like the answer. I just woke up from a nap and will go
> try it. I already knew part of it but when I saw the -r option in the man
> page I really was not sure how to use it. Your example makes it clear. I
> was already planning to mv the needed files to their own directory, process
> them and mv them back which makes thing easier as you said.
>
> Thanks again MM,
> Larry
>
>
> On Sat, Mar 30, 2013 at 1:45 AM, Matrix Mole <matrixm at gmail.com> wrote:
>
>> Remember that touch will update the file relative to "now" instead of the
>> existing date stamp on the file. Also, the -d option to touch can take the
>> exact same information as the -d option for the date command. The -r option
>> will make touch work relevant to the existing time stamp of the file. So,
>> what you want should just be this 'touch -r file -d "+14 hours" file' as
>> thus:
>>
>> $ ls -l test; touch -r test -d "+14 hours" test; ls -l test
>> -rw-r--r-- 1 matrixm matrixm 0 Mar 27 04:17 test
>> -rw-r--r-- 1 matrixm matrixm 0 Mar 27 18:17 test
>>
>> The -r option requires a filename to operate against (I discovered this
>> during my testing while writing this up), so you need to list the file
>> twice. You should be able to use a for loop, replacing both calls to the
>> filename with a variable instead to quickly do all of the files, just be
>> careful of your regex so that it doesn't accidentally catch files with the
>> correct timestamp already (I always merely output the resulting files of a
>> regex with an echo command before continuing writing a file modification
>> loop). Unless, that is, you have the files that need the timestamp modified
>> in their own directory. If that's the case, then you could do:
>>
>> for FILE in filestobemodified/*; do ls -l $FILE; touch -r $FILE -d '+14
>> hours' $FILE; ls -l $FILE; done
>>
>> I would suggest holding off on running that one liner until you know for
>> certain that the touch command with the -r and -d options will give you the
>> result you want.
>>
>>
>> On Sat, Mar 30, 2013 at 12:54 AM, Dazed_75 <lthielster at gmail.com> wrote:
>>
>>>
>>>
>>>
>>> On Fri, Mar 29, 2013 at 4:42 PM, der.hans <PLUGd at lufthans.com> wrote:
>>>
>>>> Am 29. Mar, 2013 schwätzte Dazed_75 so:
>>>>
>>>> moin moin,
>>>>
>>>>
>>>> Looking to change some file dares to 14 hours later than the current
>>>>> file
>>>>> date/time stamps (they are NOT all the same). I was thinking some
>>>>> form of
>>>>> the -d option would work but nothing I have tried works-
>>>>>
>>>>
>>>> $ date; touch -d "$( date -d "+14 hours" +%Y%b%d )" /tmp/fred; ls -l
>>>> /tmp/fred Fr 29. Mär 16:57:45 MST 2013
>>>> -rw-r--r-- 1 lufthans lufthans 0 2013-03-30 01:13 /tmp/fred
>>>>
>>>> The "+14 hours" only works with GNU date, but that's what we get on
>>>> GNU/Linux. BSD date really didn't like it :).
>>>>
>>>> ciao,
>>>>
>>>> der.hans
>>>>
>>>
>>> This is close but not quite. Maybe I could have explained it better. I
>>> have taken a LOT if video clips here in Thailand. Unfortunately, the
>>> camera clock was still set for Arizona time until several days into the
>>> trip. Now that I have fixed that I want to re-timestamp the first 100 or
>>> so to have the timestamp adjusted +14 hours. Here is what I get from
>>> der.Hans' script:
>>>
>>> larry at sunfish:~/tempwork$ ls -l target; date; touch -d "$( date -d
>>> "+14 hours" +%Y%b%d )" target; ls -l target
>>> -rw-rw-r-- 1 larry larry 0 Mar 24 18:18 target
>>> Fri Mar 29 23:55:49 MST 2013
>>> touch: invalid date format `2013Mar30'
>>> -rw-rw-r-- 1 larry larry 0 Mar 24 18:18 target
>>> larry at sunfish:~/tempwork$
>>>
>>>
>>> I can fix the date format I believe, but the target's timestamp should
>>> end up being Mar 25 08:18, not Mar 30 13:55. The reason I want a script or
>>> compound command to do it is so i don't have to figure out the +14 hours
>>> 100+ times and issue 100+ touch commands.
>>>
>>> Thanks, I hope I can get the timestamp extracted to a variable and use
>>> that to replace the date command (if I don't fall asleep first :-)
>>>
>>> Larry
>>>
>>>
>>>
>>>
>>>> --
>>>> # http://www.LuftHans.com/ http://www.LuftHans.com/**Classes/<http://www.LuftHans.com/Classes/>
>>>> # Free, Libre, and Open Source enthusiasts are collaborators. Maybe
>>>> we're
>>>> # involved for slightly different reasons, but in the end, we're all
>>>> # essentially trying to go the same direction. -- der.hans, 2012Jan25
>>>> ---------------------------------------------------
>>>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>>>> To subscribe, unsubscribe, or to change your mail settings:
>>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>>
>>>
>>>
>>>
>>> --
>>> Dazed_75 a.k.a. Larry
>>>
>>> Please protect my address like I protect yours. When sending messages to
>>> multiple recipients, use the BCC: (Blind carbon copy). Remove addresses
>>> from a forwarded message body before clicking Send.
>>>
>>> ---------------------------------------------------
>>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>>> To subscribe, unsubscribe, or to change your mail settings:
>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>
>>
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>
>
>
> --
> Dazed_75 a.k.a. Larry
>
> Please protect my address like I protect yours. When sending messages to
> multiple recipients, use the BCC: (Blind carbon copy). Remove addresses
> from a forwarded message body before clicking Send.
>
--
Dazed_75 a.k.a. Larry
Please protect my address like I protect yours. When sending messages to
multiple recipients, use the BCC: (Blind carbon copy). Remove addresses
from a forwarded message body before clicking Send.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20130330/dc163a6c/attachment.html>
More information about the PLUG-discuss
mailing list