You are viewing documentation generated from a user contribution or an upcoming release. The contents of this document may not have been reviewed by the Deno team. Click here to view the documentation for the latest release.

An Implementation of the Unix "cat" Program


  • Use the Deno runtime API to output the contents of a file to the console.
  • Deno.args accesses the command line arguments.
  • is used to get a handle to a file.
  • copy is used to transfer data from the file to the output stream.
  • Files should be closed when you are finished with them
  • Modules can be run directly from remote URLs.


In this program each command-line argument is assumed to be a filename, the file is opened, and printed to stdout (e.g. the console).

 * cat.ts
import { copy } from "";
for (const filename of Deno.args) {
  const file = await;
  await copy(file, Deno.stdout);

To run the program:

deno run --allow-read /etc/passwd