BlogBlog ÜbersichtjailscriptportsoptFreeBSDLinksThermoskanneKontakt

Zugriffs- und Modifikationszeit einer Datei ändern

Mit Hilfe der -a Option von touch kann die Zugriffszeit einer Datei verändert werden. Mit der -t Option wird die neue Zeit angegeben:

# stat -f "modify: %Sm access: %Sa" testdatei
modify: Jul 31 15:04:12 2010 access: Jul 31 15:04:05 2010
# touch -a -t 198010020210 testdatei
# stat -f "modify: %Sm access: %Sa" testdatei
modify: Jul 31 15:04:12 2010 access: Oct  2 02:10:00 1980

Identisch kann mit der -m Option die Modifikationszei der Datei angepasst werden:

# touch -m -t 198010020210 testdatei
# stat -f "modify: %Sm access: %Sa" testdatei
modify: Oct  2 02:10:00 1980 access: Oct  2 02:10:00 1980

Verwendet man nur die -t Option wird sowohl die Zugriffs- als auch die Modifikationszeit der Datei geändert:

# touch -t 201010020210 testdatei
# stat -f "modify: %Sm access: %Sa" testdatei
modify: Oct  2 02:10:00 2010 access: Oct  2 02:10:00 2010

Mit der -r Option werden die Zugriffs- und Modifikationszeiten einer anderen Datei kopiert:

# stat -f "modify: %Sm access: %Sa" testdatei*
modify: Oct  2 02:10:00 2010 access: Oct  2 02:10:00 2010
modify: Jul 31 15:04:45 2010 access: Jul 31 15:04:45 2010
# touch -r testdatei2 testdatei
# stat -f "modify: %Sm access: %Sa" testdatei*
modify: Jul 31 15:04:45 2010 access: Jul 31 15:04:45 2010
modify: Jul 31 15:04:45 2010 access: Jul 31 15:04:45 2010

Auf FreeBSD ist touch standardmässig im Basissystem vorhanden. Mehr Informationen zu touch findet man in der Manpage touch(1).

Comments (0)  Permalink

Comments

add a comment

The Trackback URL to this post is:
http://www.chruetertee.ch/blog/plugin=trackback(1752).xml
Trackbacks are moderated.

This blog is gravatar enabled.
Your email adress will never be published.
Comment spam will be deleted!

Name*
E-Mail
For Spammers Only
URL
Comment*
Notify me via E-Mail when new comments are made to this entry
Remember me (needs cookies)