eolas/Programming_Languages/Shell/Read.md
2022-12-15 17:00:05 +00:00

633 B

categories tags
Programming Languages
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

$ read var1 var2
$ thomas bishop # user inputs this
$ echo $var2
$ bishop

If you don't specify variables, read will automatically parse using whitespace

stdout

find -type -f  -not -path "./.git/" | read $fname