UTYPE — Dump text files to standard output.

Syntax:
UTYPE /A:attribs /B /C /CP:n /D /E /F:string /H /HW:n /K:n /L:format /N /P /Q /S /T /U:string /X /Z:n filename…

/A:attribsattributes mask; valid flags are -ACEHIORS
/Bdiscard BEL characters (control-G, ASCII 7)
/Creplace control characters with ^ sequences
/CP:ninterpret non-Unicode input text using code page n
/Ddiscard blank lines at the start of the file
/Ediscard all empty lines
/F:stringshow only lines following this string; /FF: inclusive
/Hdisplay the filename before each file
/HHdisplay the filename, file size, and encoding before each file
/HW:nhex dump width, in bytes; only useful with /X
/K:nexpand tabs to n columns
/L:formatinsert line numbers on the left
/Ndisable features
/Ppage output
/Qreplace ASCII quotes and apostrophes with Unicode open and close quotes
/Ssearch in subdirectories for matching files
/Ttrim leading and trailing whitespace
/U:stringshow only lines until (before) this string; /UU: inclusive
/Xdump file in hexadecimal
/Z:handling of NUL characters in text:
    /Z:N — treat like end-of-line (default)
    /Z:I — treat as invalid character
    /Z:S — skip over (ignore) any NUL characters
  
Range options are also supported.

UTYPE displays files to standard output, much like the internal TYPE command. The primary advantage of UTYPE is that it recognizes and handles UTF-8 text files; you can think of it as a ‘UTF-8 TYPE’.

If you want to pipe to UTYPE, remember that pipes open a new shell. To pipe to a plugin command, you must either ensure that the plugin is loaded in the transient shell, e.g. by installing the .DLL file in the shell’s PlugIns directory; or else use temporary files or an in-process pipe.

If standard input (stdin) is redirected, UTYPE will read from stdin before any filenames specified on the command line. If no filenames are specified, then UTYPE will read from stdin whether it is redirected or not. Filenames may include wildcards and directory aliases. You can search into subdirectories for matching files with /S. @File lists and internet files are supported. You may also specify CLIP: to display the contents of the clipboard.

If you include /L on the command line, UTYPE will insert line numbers on the left, starting at 1, as TYPE does. If you include the optional format string, UTYPE will perform variable expansion on the string before displaying it; use the variable _LINE to get the current (zero-based) line number. For example, /L:"%%@FORMAT[03,%%_LINE] " will show the line number zero-padded to at least three digits.

/F: and /U: can be used to chop off a simple header or footer. /F: discards all lines up to and including the first line which contains the specified string (case-insensitive); /U: discards all lines including and after a line which contains the specified string (again, case-insensitive). For example, most Project Gutenberg ebooks include a header which ends in a line beginning with “*** START” and a footer beginning with “*** END”. You can strip them off like this:

utype "http://www.gutenberg.org/cache/epub/11/pg11.txt" /f:"*** start" /u:"*** end" /d | list

If you double the option letter — /FF: or /UU: — the matching line will be included in UTYPE’s output, not discarded.

/E discards all blank lines; /D discards only those at the start of a file. If you specify both, /D wins. If you combine /D with /F:string, UTYPE will discard any blank lines following the header. A line containing only spaces or tabs is considered blank.

/N disables features:

/NBdo not write a Byte Order Mark
/NCdisable highlight
/NDdo not search into hidden directories; only useful with /S
/NFsuppress the file-not-found error
/NHdisable the handbrake
/NJdo not search into junctions; only useful with /S
/NZdo not search into system directories; only useful with /S

You can combine these, e.g. /NDJ.


The handbrake: When scrolling a long file to the console and /P was not specified, UTYPE watches for the Ctrl and Esc keys. Hold down the Ctrl key to slow the scrolling; press Esc to pause the file as if /P had been specified. This feature will be disabled automatically if you specify /P or if output is redirected; you can also disable it with /NH.


Quotes replacement: /Q causes UTYPE to replace generic ASCII apostrophes and quote marks ( ' and " ) with Unicode open and close quote marks (   and    ). The new quote marks may or may not look different from the originals, depending on how they are displayed and the font used. If the output is displayed in a non-Unicode font, the curly quotes will be lost or mangled. You can set some environment variables to control this feature.


utype "Engine Summer.txt"