From 67bd728fedcee73742388d7aadbcd75858809149 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Thu, 15 Dec 2022 17:00:05 +0000 Subject: [PATCH] Autosave: 2022-12-15 17:00:05 --- Programming_Languages/Shell/Read.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Programming_Languages/Shell/Read.md b/Programming_Languages/Shell/Read.md index e69de29..7a5f8d4 100644 --- a/Programming_Languages/Shell/Read.md +++ b/Programming_Languages/Shell/Read.md @@ -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 +```