I have several thousands of automatically saved web-pages, proceeding from different sources. Many of the web-pages have embedded fonts in files like *.woff, *.eot, *.ttf, and *.svg. I'd like to reduce the size of these, deleting all font files. How can I test whether a file is for fonts? It's clear that I can find some with find . -type f -name *woff. Specially, confusion is possible with *svg files. A *svg file can be either a font file like xxxwebfontsxxx.svg or it can be a perfectly informative image.If it's not possible to test the files directly, what extensions should I delete? The font files that I know by extension are *otf, *ttf, *eot, *woff and some *svg can be fonts or not. Is it save to delete these first four types of file?
How to test whether a file is a font file
files;fonts
There's a command called file that makes (good but not always perfect) guesses about the file type. One way to use that command could be:find your_web_pages_directory -type f -name *.* -print0 |  xargs -0 file |    awk 'BEGIN{FS=: +}$2~/[Ff]ont/{print $1}' |      xargs rm --The find command looks for ordinary files with extensions (you may restrict that extension further if you like), the awk program matches the  guess from the preceding guess by file and prints the filename, and finally the result is removed. Depending on what files you have in your_web_pages_directory it may be advisable to first inspect the output of the find | xargs pipeline before you add the awk and rm parts of the pipeline.Note: The code assumes that file will report anything like Font or font for the desired files. If that is not the actual diagnostic string you'd have to change that accordingly. Make some tests on files where you know they are of the type you are searching.