summaryrefslogtreecommitdiff
path: root/recentlymodifiedfilesrec.sh
diff options
context:
space:
mode:
authorgrothedev <grothedev@gmail.com>2024-06-17 13:26:56 -0500
committergrothedev <grothedev@gmail.com>2024-06-17 13:43:08 -0500
commit702ad77194129290cfd4d2b45fcf15f862a84750 (patch)
tree4872f00743dca0a66bd01485204f67758c225d77 /recentlymodifiedfilesrec.sh
parent5a6bec76248cdc6400cc6c7fdf5fcebf84ff57c4 (diff)
better and faster finding most recently modified files recursively. also a process monitoring script i used to keep track of when vscode-server started acting up
Diffstat (limited to 'recentlymodifiedfilesrec.sh')
-rwxr-xr-xrecentlymodifiedfilesrec.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/recentlymodifiedfilesrec.sh b/recentlymodifiedfilesrec.sh
new file mode 100755
index 0000000..2ba7f80
--- /dev/null
+++ b/recentlymodifiedfilesrec.sh
@@ -0,0 +1,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"