Skip to content

Instantly share code, notes, and snippets.

@geta6
Created June 9, 2012 12:52
Show Gist options
  • Save geta6/2900870 to your computer and use it in GitHub Desktop.
Save geta6/2900870 to your computer and use it in GitHub Desktop.
findとphpで、あるディレクトリ内のファイルを再帰的に日付順でソートして出力するですよー
<?php
exec('find $DIR -type f -print0 | xargs -0 ls -lt --time-style=long-iso "{}" 2>/dev/null', $e);
// -maxdepth
// -mindepth
// -mtime
preg_match_all('|[0-9]{2,}? +(.+?) (/.+)|', implode("\n",$e), $m, PREG_SET_ORDER);
foreach ($m as $val) {
echo strtotime($val[1]) .' ' . $val[2] . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment