Software & AppsOperating SystemLinux

How To Find Infected Files from ClamAv Scan Results

Ubuntu 1

In this article, we will walk you through how to find infected files using ClamAV scan results. ClamAV is a powerful open-source antivirus engine designed to detect Trojans, viruses, malware, and other malicious threats.

Quick Answer

To find infected files from ClamAV scan results, you can use the clamscan command followed by the directory you want to scan. After running the scan, you can filter the results to show only the infected files using the grep command. ClamAV will indicate infected files with the word ‘FOUND’. Additionally, you can use the -i option with the clamscan command to print only the paths of infected files.

Understanding ClamAV

ClamAV is a versatile tool that can be used in various ways to protect your system. It offers a command-line scanner, automatic database updates, and a scalable multi-threaded daemon.

To install ClamAV on your system, use the following command:

sudo apt-get install clamav

Scanning for Infected Files

Once you have ClamAV installed, you can start scanning your files. To do this, you use the clamscan command followed by the directory you wish to scan. For instance, to scan a directory called /folder/to/scan/, you would use the following command:

sudo clamscan -r /folder/to/scan/

In this command, -r is a parameter that tells ClamAV to scan directories recursively, meaning it will scan all files within the directory and its subdirectories.

Identifying Infected Files

After running the scan, ClamAV will display the results in the terminal. However, if you want to filter these results to show only the infected files, you can use the grep command.

sudo clamscan -r /folder/to/scan/ | grep FOUND >> /path/to/save/report/file.txt

Here, grep is a command-line utility that searches and filters out the lines containing a specific pattern. In this case, it filters out lines containing the word ‘FOUND’, which ClamAV uses to indicate infected files. The >> operator is used to append these lines to a report file located at /path/to/save/report/file.txt.

Alternatively, you can use the -i option with the clamscan command to print only the infected files.

clamscan -ir /folder

In this command, -i stands for ‘infected’, so ClamAV will only print the paths of infected files.

Important Considerations

While ClamAV is a powerful tool for identifying infected files, it does not disinfect files. Therefore, you must handle the infected files carefully. Deleting an infected file without understanding its importance could lead to unintended consequences, especially if the file is critical for a program or contains unsaved data.

For more information on ClamAV and its usage, you can refer to the Ubuntu Community Help Wiki.


In conclusion, ClamAV is a versatile and powerful tool that can help you identify infected files on your system. By understanding how to use the clamscan command and filter its results, you can effectively locate and handle infected files. Always remember to handle infected files with care to avoid any potential damage to your system or loss of data.

How often should I run a ClamAV scan?

It is recommended to run a ClamAV scan regularly, ideally at least once a week, to ensure timely detection of any infected files.

Can ClamAV remove or disinfect infected files?

No, ClamAV is primarily designed to detect and identify infected files. It does not have the capability to remove or disinfect them. You will need to manually handle and remove infected files from your system.

Can ClamAV scan specific file types?

Yes, ClamAV can scan specific file types. To scan specific file types, you can use the --include or --exclude options followed by the file extensions you want to include or exclude from the scan.

How can I update the ClamAV database?

ClamAV offers automatic database updates, but you can also manually update the database using the freshclam command. Running sudo freshclam will update the ClamAV virus database to ensure you have the latest definitions for detecting malware and viruses.

Can I use ClamAV on Windows or macOS?

Yes, ClamAV is available for Windows and macOS in addition to Linux. You can download the appropriate version of ClamAV for your operating system from the official ClamAV website.

Leave a Comment

Your email address will not be published. Required fields are marked *