Search code examples
stdinfish

How to read from stdin with fish shell


With bash, we had the possibility to read multilines from stdin like this cat << END. When I try the same command from the fish shell, I get this error Expected a string, but instead found a redirection.

Is there a way to read from stdin with the fish shell ??!!


Solution

  • "Heredocs", which are the feature you are referring to, are not in fish. This is because their main function is

    cat <<END
    some 
    multiline 
    string 
    END
    

    , which can be replicated by just using echo with a multiline literal, like

    echo "some
    multiline
    string"
    

    or printf "%s\n" with one argument per line, like

    printf "%s\n" "some" "multiline" "string"