deno.com

Unix cat

在 Github 上编辑

In Unix, the `cat` command is a utility that reads files and writes them to standard output. You can use Deno to mimic the behavior of the `cat` command.

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).

Create a script that reads the contents of one or more files and writes them to standard output.
for (const filename of Deno.args) {
  const file = await Deno.open(filename);
  await file.readable.pipeTo(Deno.stdout.writable, { preventClose: true });
}

使用 Deno CLI 在本地运行 此示例

deno run --allow-read cat.ts file1 file2

你找到需要的内容了吗?

隐私政策