blob: e475c1bfa89f1a8f4d78441708367bb9d4549089 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/sh
usage()
{
cat <<EOF
Usage: $0 [directory] [...]
Print the filename of the newest file.
Searches the directories specified on the command line,
or else the current directory if none specified.
EOF
}
case $# in
0) set -- . ;;
1) if [ "$1" = --usage ]; then usage; exit 0; fi ;;
esac
extract()
{
sort -z -n -k1,1 -r | head -z -n 1 | xargs -0 printf '%s\n' | cut -d' ' -f2
}
find "$@" -maxdepth 1 -name '.*' -o \( -type f -printf "%C@ %h/%f\0" \) | extract
|