Skip to main content
Quote RHS to prevent interpretation as shell pattern
Source Link
Benjamin W.
  • 50.1k
  • 19
  • 122
  • 124

With only Bash builtins, closely following BashFAQ/003:

shopt -s nullglob

for f in * .*; do
    [[ -d $f ]] && continue
    [[ $f -nt $latest"$latest" ]] && latest=$f
done

printf '%s\n' "$latest"

With only Bash builtins, closely following BashFAQ/003:

shopt -s nullglob

for f in * .*; do
    [[ -d $f ]] && continue
    [[ $f -nt $latest ]] && latest=$f
done

printf '%s\n' "$latest"

With only Bash builtins, closely following BashFAQ/003:

shopt -s nullglob

for f in * .*; do
    [[ -d $f ]] && continue
    [[ $f -nt "$latest" ]] && latest=$f
done

printf '%s\n' "$latest"
Source Link
Benjamin W.
  • 50.1k
  • 19
  • 122
  • 124

With only Bash builtins, closely following BashFAQ/003:

shopt -s nullglob

for f in * .*; do
    [[ -d $f ]] && continue
    [[ $f -nt $latest ]] && latest=$f
done

printf '%s\n' "$latest"