#!/usr/bin/env bash #------------------------------------------------------------------------------ # Path - /usr/bin/clipmenu-cache # GitHub - https://github.com/The-Repo-Club/ # Author - The-Repo-Club [wayne6324@gmail.com] # Start On - Tue 05 Oct 16:09:16 BST 2021 # Modified On - Sun 31 Oct 00:32:01 BST 2021 #------------------------------------------------------------------------------ shopt -s nullglob cache_dir=$(clipmenu-ctl cache-dir) cache_file=$cache_dir/line_cache declare -A cksums while IFS= read -r line; do cksum=$(cksum <<< "$line") cksums["$cksum"]="$line" # Are all cache entries represented by a file? full_file=$cache_dir/$cksum if ! [[ -f $full_file ]]; then printf 'cache entry without file: %s -> %s\n' "$line" "$full_file" >&2 fi done < <(cut -d' ' -f2- < "$cache_file") # Are all files represented by a cache entry? for file in "$cache_dir"/[012346789]*; do cksum=${file##*/} line=${cksums["$cksum"]-_missing_} if [[ $line == _missing_ ]]; then printf 'file without cache entry: %s\n' "$file" fi done