-
-
Save aiya000/e7ce3e9909f122b60c464af0200bf905 to your computer and use it in GitHub Desktop.
Progress for clamdscan.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This respects the following original script: | |
# - Original: https://gist.github.com/nemasu/9d89d2998822980a07284bf442342482 | |
# | |
# I'm also developing the newer version at here: | |
# - Support: https://github.com/aiya000/bash-toys | |
if [[ $# -eq 0 ]] ; then | |
target_paths=(/) | |
else | |
target_paths=("$*") | |
fi | |
if command -v fdfind > /dev/null 2>&1 ; then | |
find_target_paths="fdfind . ${target_paths[*]} --min-depth 1 --exclude \"/{proc,sys,run,dev,snap,mnt}\" --type d" | |
elif command -v fd > /dev/null 2>&1 ; then | |
find_target_paths="fd . ${target_paths[*]} --min-depth 1 --exclude \"/{proc,sys,run,dev,snap,mnt}\" --type d" | |
else | |
find_target_paths="find ${target_paths[*]} -mindepth 1 -not -path \"/proc\" -not -path \"/sys\" -not -path \"/run\" -not -path \"/dev\" -not -path \"/snap\" -not -path \"/mnt\" -type d" | |
fi | |
logfile="/tmp/clamdscan_$(date '+%Y-%m-%d-%H-%M').log" | |
count=0 | |
function show_progress () { | |
echo -ne "\r" | |
echo -n "$(echo "scale=5; ($count / $total) * 100" | bc)" | |
} | |
IFS=$'\n' | |
touch "$logfile" | |
total=$(eval "$find_target_paths" | wc -l) | |
for dir in $(eval "$find_target_paths" 2>/dev/null) ; do | |
count=$((count + 1)) | |
show_progress | |
echo "$dir" >> "$logfile" | |
for file in $(fdfind --full-path "$dir" --min-depth 1 --max-depth 1 --type f 2>/dev/null) ; do | |
clamdscan --fdpass --quiet "$file" | |
done | |
done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original: https://gist.github.com/nemasu/9d89d2998822980a07284bf442342482