"while read" in a Shell Script and reading from a Variable

  • Hi,

    on Ubuntu with Bash when i want to read from a variable in "while read" it's possible with:

    Code
    while read line; do
     echo $line
    done <<< $var

    This doesn't work in a shell script (shebang = #!/bin/sh) on LibreELEC. I get the error:

    Quote

    syntax error: unexpected redirection

    When i try '<<' instead of '<<<' there is not error but also no echo output.

  • The bash extension "<<<" is not available in busybox ash - even with enabled bash extensions. Use

    Bash
    while read line; do
     echo $line
    done <<EOF
    $var
    EOF