Skip to content

Instantly share code, notes, and snippets.

@ChristopherHaws
Created July 19, 2023 17:34
Show Gist options
  • Save ChristopherHaws/5eb5e6508e74e4633140822a7ef0b4a1 to your computer and use it in GitHub Desktop.
Save ChristopherHaws/5eb5e6508e74e4633140822a7ef0b4a1 to your computer and use it in GitHub Desktop.
scan file for virus and move it if it is clean
#!/bin/bash
SRC_DIR="/source/directory/path"
DEST_DIR="/destination/directory/path"
LOG_FILE="/path/to/clamscan.log"
find "$SRC_DIR" -type f | xargs -I {} -P $(nproc) sh -c "
if clamscan -i --no-summary '{}'
then
rsync -avz --progress '{}' '$DEST_DIR'
else
echo '{} is infected and not copied' | tee -a '$LOG_FILE'
fi
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment