Autosave: 2022-12-15 17:00:05

This commit is contained in:
thomasabishop 2022-12-15 17:00:05 +00:00
parent 80cb82e0bf
commit 67bd728fed

View file

@ -0,0 +1,27 @@
---
categories:
- Programming Languages
tags:
- shell
---
# `read`
`read` is primarily used to capture `stdin` from the user and automatically parse it as variables. It has a secondary use case as a command that the `stdout` is piped to. This enables you to capture the output of a command as one or more variables which you can then execute subsequent operations on.
## `stdin`
```bash
$ read var1 var2
$ thomas bishop # user inputs this
$ echo $var2
$ bishop
```
> If you don't specify variables, `read` will automatically parse using whitespace
## `stdout`
```bash
find -type -f -not -path "./.git/" | read $fname
```