]> git.nbdom.net Git - nb.git/commitdiff
find-sort-mtime
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Jun 2015 15:51:15 +0000 (16:51 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Jun 2015 15:51:15 +0000 (16:51 +0100)
etc/bashrc.function

index 9bc6d541878ca4d26493eb1d2964c6e325f81d59..5324d383519c616dcfdee437438b97d20102b822 100644 (file)
@@ -239,8 +239,12 @@ ls-tree() {
 }
 
 find-sort-mtime() {
-  #find $@ -type f -printf "%Tk\t%p\n" | sort -k1 -nr|cut -f2
-  find $@ -type f -printf "%T@\t%p\n" | sed 's/^\([0-9]\+\)\.0\+/\1/'|sort -k1 -n | cut -f 2 | head
+  (
+    case "$OSTYPE" in 
+      darwin*) find $@ -type f -exec stat -f '%m %N' {} \; ;;
+      *) find $@ -type f -printf "%T@\t%p\n" | sed 's/^\([0-9]\+\)\.0\+/\1/' ;;
+    esac
+  ) | sort -k1 -n | cut -f 2 | head
 }
 
 nb-alert() {