What are common heredoc delimiters?

0165

Common heredoc delimiters in Linux shell scripting can be any string, but there are a few conventions that are frequently used. The most common delimiters include:

  1. EOF: This is the most widely used delimiter. It stands for "End Of File."

    command <<EOF
    content
    EOF
  2. END: Another popular choice, similar to EOF.

    command <<END
    content
    END
  3. HEREDOC: This is also used, especially when the purpose of the heredoc is to be more descriptive.

    command <<HEREDOC
    content
    HEREDOC
  4. CUSTOM_STRING: You can use any string as a delimiter, as long as it is consistent at both the start and end of the heredoc.

    command <<CUSTOM_STRING
    content
    CUSTOM_STRING

The choice of delimiter is flexible, but it's important to ensure that the chosen delimiter does not appear in the content of the heredoc itself. This prevents confusion and ensures proper termination of the heredoc.

0 Comments

no data
Be the first to share your comment!