linux - Fast way to check timestamp of files in directory tree -
i need check file structure in directory tree every second, script taking long suspect collecting timestamps , calculating base64 it's name takes time in large directory tree.
how can gather tree structure, store them in array, , loop through each file collecting timestamp in array, array key cipher file path?
later i'm comparing array older version , adds additional wasted time, improve efficiency.
shopt -s globstar dotglob files=("$base"/**) new() { keys=("${!files_new[@]}") in "${keys[@]::2}" unset "files_new[$i]" done file in "${files[@]}" stamp=$(stat -c "%y" "$file") hash=$(echo "$file" | base64) files_new[$hash]=$stamp done }
i have achieved faster probing using find
command -printf
output suggested peter cordes. loop went 3 seconds 300 milliseconds.
loop() { while read string stamp=${string%|*} file=${string#*|} files_new[$file]=$stamp done < <(find "${base}" -name "*" -printf "%td%tt|%p\n") }
Comments
Post a Comment