How to remove the `#` and `;` comments and empty lines from a configuration file?

sed -i -r '/^[\s\t]*[#;]/d' <file>
# 2024-07-28
# The previous command does not remove comments from lines indented with spaces (for an unknown reason).
# So I remove these comments using another command below.
sed -i -r '/^\s+[#;]/d' <file>
sed -i -r '/^\s*$/d' <file>

See also: How to remove comments and empty lines from a php.ini?

For all files *.conf files in the current folder and subfolders:

find . -name '*.conf' -type f -exec sed -i -r '/^[\s\t]*[#;]/d' {} +
# 2024-07-28
# The previous command does not remove comments from lines indented with spaces (for an unknown reason).
# So I remove these comments using another command below.
find . -name '*.conf' -type f -exec sed -i -r '/^\s+[#;]/d' {} +
find . -name '*.conf' -type f -exec sed -i -r '/^\s*$/d' {} +