PROJET AUTOBLOG


Links

source: Links

⇐ retour index

stat et touch sur un fichier

jeudi 23 avril 2015 à 15:29
# %y = time of last modification, human-readable
$ stat -c %y file.txt
2012-09-15 20:13:46.000000000 +0200

# %Y = time of last modification, seconds since Epoch
$ stat -c %Y file.txt
1347732826

# %X = time of last access, seconds since Epoch
$ stat -c %X file.txt
1429794397

# %Z = time of last change, seconds since Epoch
$ stat -c %Z file.txt
1429794395

# changer la date de modification
touch -m -d "2012-09-15 20:13:46.000000000 +0200" file.txt

# changer la date d'accès
touch -a -d "2012-09-15 20:13:46.000000000 +0200" file.txt

# Lister les dates de modification des fichiers du dossier courant avec leur nom et trier par date:
$ for f in *; do echo `stat -c %y "$f"`" $f"; done | sort -n
2010-01-04 12:21:49.824751464 +0100 fichier2.txt
2015-04-23 15:34:31.409791999 +0200 fichier1.txt
2015-04-23 15:34:52.269791999 +0200 fichier4.txt
2015-06-08 02:29:02.552849671 +0200 fichier3.txt
(Permalink)