The `read` command

Other topics

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

Contributors

Topic Id: 3954

Example Ids: 13794,13795

This site is not affiliated with any of the contributors.