15 lines
446 B
Bash
Executable File
15 lines
446 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# description: Find files by name/path pattern, sorted by modification time (newest first)
|
|
# Args: <pattern> [path]
|
|
|
|
pattern="$1"
|
|
search_path="${2:-$PWD}"
|
|
|
|
[ -z "$pattern" ] && echo "error: pattern is required" && exit 1
|
|
|
|
# collect matches and sort by mtime descending
|
|
rg --no-config --files -g "$pattern" "$search_path" 2>/dev/null \
|
|
| xargs -d '\n' stat --printf '%Y\t%n\n' 2>/dev/null \
|
|
| sort -rn \
|
|
| cut -f2-
|