I know how to scan one directory:

clamscan -r /home

but for the life of me I cannot seem to get multiple directories working and I cannot seem to Google this simple problem.

I have tried:

clamscan -r /home /otherdir
clamscan -r /home,/otherdir

to no avail.

What am I doing wrong?


You have to put the list of folders/files in a text file and pass it to clamscan using -f.

clamscan -r -z -i --bell --file-list=/home/nav/ClamScanTheseFolders.txt

  • Aha, I see it on the man page now, seemed to overlook the f option thanks – Sammaye Dec 24 '15 at 11:42
DIRTOSCAN="/home /var/spool /bin /sbin";
for S in ${DIRTOSCAN}; do
  clamscan -ri "$S" >> "$LOGFILE";

Credit: https://www.howtoforge.com/tutorial/configure-clamav-to-scan-and-notify-virus-and-malware/


Note that currently in Debian 10, I can scan two directories by simply passing them both at the command line:

clamscan -irv /root/test1/ /root/test2/

The switches stand for:

  • v: verbose, to get the output
  • i: infected only
  • r: recursive

This will result in:

Scanning /root/test1/a.php
Scanning /root/test2/b.php

----------- SCAN SUMMARY -----------
Known viruses: 6849828
Engine version: 0.102.2
Scanned directories: 2
Scanned files: 2
Infected files: 0
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 15.759 sec (0 m 15 s)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.