#!/usr/bin/env bash # description: Find files by name/path pattern, sorted by modification time (newest first) # Args: [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-