Skip to content

Instantly share code, notes, and snippets.

@brwyatt
Last active January 22, 2025 19:20

Revisions

  1. brwyatt revised this gist Aug 23, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion findNewestFile.sh
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,4 @@ fi

    # Based on https://stackoverflow.com/questions/10575665/linux-find-command-find-10-latest-files-recursively-regardless-of-time-span
    # with additions to return only the date of the newest file
    find "${dir}" -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d' ' -f2 | xargs ls -l | cut -d' ' -f6,7,8
    find "${dir}" -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d' ' -f2 | xargs ls -l -t
  2. brwyatt revised this gist Dec 29, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions findNewestFile.sh
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,6 @@ else
    dir="${1}"
    fi

    # Based on https://stackoverflow.com/questions/10575665/linux-find-command-find-10-latest-files-recursively-regardless-of-time-span
    # with additions to return only the date of the newest file
    find "${dir}" -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d' ' -f2 | xargs ls -l | cut -d' ' -f6,7,8
  3. brwyatt created this gist Dec 29, 2015.
    9 changes: 9 additions & 0 deletions findNewestFile.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/bash

    if [[ "x${1}" == "x" ]]; then
    dir="."
    else
    dir="${1}"
    fi

    find "${dir}" -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d' ' -f2 | xargs ls -l | cut -d' ' -f6,7,8