diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-07-20 16:25:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 16:25:36 +0200 |
commit | d744c0c6d9a557bbaa2a23571ffb3acabf19c35a (patch) | |
tree | 6f7fb8a71b786e79c48f4b2c11a5a9ca988717e8 /docs/examples/unix_cat.md | |
parent | 9b9becf1ae256b645e37a7eecf3441f3ae4b8ea5 (diff) |
chore: move docs to separate repository
Diffstat (limited to 'docs/examples/unix_cat.md')
-rw-r--r-- | docs/examples/unix_cat.md | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/docs/examples/unix_cat.md b/docs/examples/unix_cat.md deleted file mode 100644 index 0ce28d718..000000000 --- a/docs/examples/unix_cat.md +++ /dev/null @@ -1,36 +0,0 @@ -# An implementation of the unix "cat" program - -## Concepts - -- Use the Deno runtime API to output the contents of a file to the console. -- [Deno.args](https://doc.deno.land/builtin/stable#Deno.args) accesses the - command line arguments. -- [Deno.open](https://doc.deno.land/builtin/stable#Deno.open) is used to get a - handle to a file. -- [copy](https://doc.deno.land/https/deno.land/std@$STD_VERSION/io/util.ts#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. - -## Example - -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). - -```ts -/** - * cat.ts - */ -import { copy } from "https://deno.land/std@$STD_VERSION/io/util.ts"; -for (const filename of Deno.args) { - const file = await Deno.open(filename); - await copy(file, Deno.stdout); - file.close(); -} -``` - -To run the program: - -```shell -deno run --allow-read https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd -``` |