]>
zdv2.bktei.com Git - BK-2020-03.git/blob - user/bkotsgu
2 # Desc: Updates all ots files in $HOME and /mnt/ directories recursively.
3 # Depends: bash 5.1.16, GNU Findutils 4.8.0, GNU Coreutils 8.32
5 # Depends: GNU Coreutils (nproc)
9 declare -a find_targets
;
11 ## User home directory
12 find_targets
+=("$HOME");
14 ## Subdirectories of /mnt/
15 mapfile
-t -O "${#find_targets[@]}" find_targets
< <(find /mnt
/ -mindepth 1 -maxdepth 1 -type d
; );
18 find_depth
=12; # find directory depth
19 cpu_count
="$(nproc)"; # get logical CPU count
20 batch_size_xargs
=100; # xargs batch size
21 cpu_duty
="$((cpu_count / 4 + 1))"; # logical CPU cores to use
23 # Remove OTS backup files
24 find "${find_targets[@]}" -maxdepth "$find_depth" -type f
-name "*.ots.bak" -exec rm '{}' \
; 2>/dev
/random
;
27 find "${find_targets[@]}" -maxdepth "$find_depth" -type f
-name "*.ots" -print0 2>/dev
/random | \
30 xargs -0 -n "$batch_size_xargs" -P "$cpu_duty" ots u
;