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?

Sammaye
  • 719
  • 1
  • 8
  • 16

3 Answers3

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

Nav
  • 103
  • 4
Florin Asăvoaie
  • 7,057
  • 23
  • 35
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/

storm_m2138
  • 171
  • 2
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)
Wadih M.
  • 1,032
  • 1
  • 10
  • 18