From 547fbdc4205ce59ca97ae6f87f20c8731a5be84e Mon Sep 17 00:00:00 2001 From: Gabe Mudel <46403658+gmudel@users.noreply.github.com> Date: Mon, 7 Oct 2019 15:03:40 -0400 Subject: [PATCH] Added documentation to the file command --- _commands/tools/file.md | 48 +++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/_commands/tools/file.md b/_commands/tools/file.md index ddbab64..64a5ce3 100644 --- a/_commands/tools/file.md +++ b/_commands/tools/file.md @@ -2,23 +2,59 @@ --- file ---- -TODO: Add documentation for this command by submitting a pull request. +------- + +`file` prints the file type of a file in a human-readable format ~~~ bash -*short* example of command usage and output +$ file test.cpp +test.cpp: c program text, UTF-8 Unicode text + ~~~ + ### Useful Options / Examples -#### Example command +Useful on Unix since file extensions sometimes are completely unrelated to their actual type. -##### Break it down +~~~bash +file starter-files.csvs +starter-files.csv: Zip archive data, at least v2.0 to extract +~~~ + +#### `file` + +~~~bash +$ file [options] filename ... +~~~ + +Options include: -#### Example command +1. `b` to only show the file type (rather than the file name followed by the file type) +2. `i` to show the file's mime type +3. `z` to view compressed files without decompressing + + +---- + +#### `file -bi filename` + +~~~bash +$ file -z bar.txt.gz +$ bar.txt.gz: ASCII text (gzip compressed data, was "bar.txt", last modified: Wed Sep 7 19:31:23 2016, from Unix) + +file -bi file.txt +file.txt: text/plain; charset=us-ascii +~~~ ##### Break it down + +* The -b option will print only the file type +* The -i option will print the file's mime type rather than a human-readable description of the file type +---- + +