2005-09-20 13:31:55 +00:00
\section read read - read line of input into variables
\subsection read-synopsis Synopsis
<tt>read [OPTIONS] [VARIABLES...]</tt>
\subsection read-description Description
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
<tt>read</tt> reads one line from standard
2014-04-19 00:16:37 +00:00
input and stores the result in one or more shell variables.
2005-09-20 13:31:55 +00:00
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
The following options are available:
- <tt>-c CMD</tt> or <tt>--command=CMD</tt> sets the initial string in the interactive mode command buffer to <tt>CMD</tt>.
2014-07-14 00:47:44 +00:00
- <tt>-g</tt> or <tt>--global</tt> makes the variables global.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
- <tt>-l</tt> or <tt>--local</tt> makes the variables local.
2010-09-18 02:18:26 +00:00
- <tt>-m NAME</tt> or <tt>--mode-name=NAME</tt> specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.
2014-08-19 12:28:08 +00:00
- <tt>-n NCHARS</tt> or <tt>--nchars=NCHARS</tt> causes \c read to return after reading NCHARS characters rather than waiting for a complete line of input.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
- <tt>-p PROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> uses the output of the shell command \c PROMPT_CMD as the prompt for the interactive mode. The default prompt command is <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
- <code>-s</code> or <code>--shell</code> enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode.
- <code>-u</code> or <code>--unexport</code> prevents the variables from being exported to child processes (default behaviour).
2014-04-19 00:16:37 +00:00
- <code>-U</code> or <code>--universal</code> causes the specified shell variable to be made universal.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
- <code>-x</code> or <code>--export</code> exports the variables to child processes.
2014-07-14 05:36:26 +00:00
- <code>-a</code> or <code>--array</code> stores the result as an array.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
\c read reads a single line of input from stdin, breaks it into tokens
2014-04-19 00:16:37 +00:00
based on the <tt>IFS</tt> shell variable, and then assigns one
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
token to each variable specified in <tt>VARIABLES</tt>. If there are more
tokens than variables, the complete remainder is assigned to the last variable.
2014-07-14 05:36:26 +00:00
As a special case, if \c IFS is set to the empty string, each character of the
input is considered a separate token.
If \c -a or \c --array is provided, only one variable name is allowed and the
tokens are stored as an array in this variable.
2005-09-20 13:31:55 +00:00
2014-07-14 00:47:44 +00:00
See the documentation for \c set for more details on the scoping rules for
variables.
2005-09-20 13:31:55 +00:00
\subsection read-example Example
2014-04-19 00:16:37 +00:00
The following code stores the value 'hello' in the shell variable
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
<tt>$foo</tt>.
2005-09-20 13:31:55 +00:00
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
<tt>echo hello|read foo</tt>