Safe File Discovery with find and xargs

Updated

October 31, 2026

Safe File Discovery with find and xargs

Filenames on Linux can contain newlines, spaces, and quotes. Always use null-byte delimiters:

find /var/log -type f -name "*.log" -mtime +30 -print0 | xargs -0 -r rm -f