file
28-10-2026 door Bernard in
Geen categorie
file bepaalt het bestandstype op basis van inhoud — niet op bestandsextensie.
Basisgebruik
file bestand
file *
Voorbeelden
file document.pdf
# document.pdf: PDF document, version 1.7
file script.sh
# script.sh: Bourne-Again shell script, ASCII text executable
file afbeelding.png
# afbeelding.png: PNG image data, 1920 x 1080, 8-bit/color RGBA
file archief.tar.gz
# archief.tar.gz: gzip compressed data, from Unix
file /bin/ls
# /bin/ls: ELF 64-bit LSB pie executable, x86-64
Opties
| Optie | Betekenis |
|---|---|
-b |
Zonder bestandsnaam (handig in scripts) |
-i |
MIME-type tonen |
-z |
Kijk ook in gecomprimeerde bestanden |
MIME-type
file -i foto.jpg
# foto.jpg: image/jpeg; charset=binary
Gebruik in scripts
TYPE=$(file -b --mime-type bestand)
if [ "$TYPE" = "application/pdf" ]; then
echo "PDF gevonden"
fi
Tip
Gebruik file als je twijfelt of een bestand is wat de extensie beweert — kwaadaardige bestanden hebben soms een misleidende naam.
Reactie? Stuur ons een bericht via ons contactformulier.