blob: 2ba7f8062969eaa090e54f27f5336aac65f23da9 (
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
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
#this is a faster implementation than the other script (mostrecentrecursively.sh)
d='.'
declare -a exclude #array of files to exclude from results
if [[ $1 ]]; then
d=$1
shift
fi
while [[ $1 ]]; do
exclude+=(${1})
shift
done
#set up the exclusion options for the find command
find_cmd_excl=""
for s in ${exclude[@]}; do
find_cmd_excl+=" -not -wholename \"*${s}*\""
done
find_cmd="find ${d} -type f ${find_cmd_excl} -printf '%T@ %p\n' | sort -n | tail -n 10 | cut -f2- -d' '"
echo $find_cmd
ts=`date +%s_%N`
eval $find_cmd
te=`date +%s_%N`
tss=`echo ${ts} | cut -d'_' -f 1`
tsn=`echo ${ts} | cut -d'_' -f 2`
tes=`echo ${te} | cut -d'_' -f 1`
ten=`echo ${te} | cut -d'_' -f 2`
echo "${tss}, ${tsn}, ${tes}, ${ten}"
tst=$((tss*1000000000 + tsn))
tet=$((tes*1000000000 + ten))
dur=$((tet-tst))
echo "duration: ${dur} ns"
|