6

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?

3 Answers 3

6

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

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

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

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

2

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)
1
  • I can confirm that works now indeed with as many directories as you wish. This should become the new accepted answer. Mar 12, 2023 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .