This is the syntax for invoking Tidy from the command line:
\code{.sh}
tidy [[options] filename]
\endcode
Tidy defaults to reading from standard input, so if you run Tidy without specifying the filename argument, it will just sit there waiting for input to read.
Tidy defaults to writing to standard output. So you can pipe output from Tidy to other programs, as well as pipe output from other programs to Tidy. You can page through the output from Tidy by piping it to a pager, e.g.:
\code{.sh}
tidy file.html | less
\endcode
\section out_file Output to file
To have Tidy write its output to a file instead, either use the
\code{.sh}
-o filename
or
-output filename
\endcode
option, or redirect standard output to the file. For example:
\code{.sh}
tidy -o output.html index.html
tidy -output output.html index.html
tidy index.html > output.html
\endcode
All the above run Tidy on the file `index.html` and write the output to the file `output.html`, while writing any error messages to standard error.
\section out_error Error output
Tidy defaults to writing its error messages to standard error (that is, to the console where you’re running Tidy). To page through the error messages along with the
output, redirect standard error to standard output, and pipe it to your pager:
\code{.sh}
tidy index.html 2>&1 | less
\endcode
To have Tidy write the errors to a file instead, either use
\code{.sh}
-f filename
or
-file filename
\endcode
option, or redirect standard error to a file:
\code{.sh}
tidy -o output.html -f errs.txt index.html
tidy index.html > output.html 2> errs.txt
\endcode
Both the above run Tidy on the file `index.html` and writes the output to the file `output.html`, while writing any error messages to the `file errs.txt`.
Writing the error messages to a file is especially useful if the file you are checking has many errors; reading them from a file instead of the console
or pager can make it easier to review them.
\section out_modify Modify / Overwrite
You can use the or `-m` or `-modify` option to modify (in-place) the contents of the input file you are checking; that is, to overwrite those contents with the output from Tidy. For example:
\code{.sh}
tidy -f errs.txt -m index.html
\endcode
That runs Tidy on the file `index.html`, modifying it in place and writing the error messages to the file `errs.txt`.
\warning If you use the `-m` option, you should first ensure that you have a backup copy of your file.