sh

The `read` command

Read a line verbatim

$ IFS= read -r foo <<EOF
>     this is a \n line
>EOF
$ printf '%s\n' "$foo"
    this is a \n line

Read a line, stripping leading and trailing whitespace

$ read -r foo <<EOF
>    this is a line
>EOF
$ printf '%s\n' "$foo"
this is a line

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow