Search code examples
shellfish

Is there a way to echo/cat a multiline message in Fish shell?


In Bash/Zsh, it is Okay using cat for a multiline message, eg:

cat <<DELIM
This is line 1
This is line 2
DELIM

However, the above code does not work for Fish Shell. Is there a way of doing so?


Solution

  • This is what I ended up using for my block of text. Read the tip about printf from faho. But wanted the code to be looking like the block itself.

    printf "\t%s\n"              \
           "###################" \
           "#                 #" \
           "# Multiline block #" \
           "#                 #" \
           "###################"
    

    %s: Is the strings encapsulated in double quotes.

    \n: New line.

    \t: Horizontal tab.

    Mixing it together inserts a tab before each line, indenting the text. And it adds a carriage return at the end of each line.