User Tools

Site Tools


bash:files:read_a_file:read_from_an_interactive_shell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bash:files:read_a_file:read_from_an_interactive_shell [2021/01/26 13:45] – created peterbash:files:read_a_file:read_from_an_interactive_shell [2021/01/26 13:56] (current) peter
Line 1: Line 1:
 ====== BASH - Files - Read a file - Read from an interactive shell ====== ====== BASH - Files - Read a file - Read from an interactive shell ======
 +
 +<code bash>
 +read foo
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  This will store the input into a variable named **$foo**.
 +</WRAP>
 +
 +----
 +
 +====== Handling backslash interpretation ======
 +
 +<WRAP info>
 +**NOTE:**  The **-r** option is often used with read:
 +
 +  * **-r**:  Prevents backslash interpretation (usually used as a backslash newline pair, to continue over multiple lines or to escape the delimiters).
 +    * Without this option, any unescaped backslashes in the input will be discarded.
 +    * You should almost always use the **-r** option with read.
 +
 +The most common exception to this rule is when **-e** is used, which uses Readline to obtain the line from an interactive shell.
 +
 +  * In that case, tab completion will add backslashes to escape spaces and such, and you do not want them to be literally included in the variable.
 +  * This would never be used when reading anything line-by-line, though, and **-r** should always be used when doing so.
 +
 +</WRAP>
 +
 +----
 +
 +
 +
  
bash/files/read_a_file/read_from_an_interactive_shell.1611668742.txt.gz · Last modified: 2021/01/26 13:45 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki